# wx.getBackgroundAudioPlayerState(Object object)
From base library 1.2.0 Start, this interface stops maintenance, please use wx.getBackgroundAudioManager replace
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6
Gets background music playback status.
# parameter
# Object object
| attribute | type | Default values | Required | Introductions |
|---|---|---|---|---|
| success | function | no | Interface calls the successful callback function | |
| fail | function | no | Interface calls failed callback functions | |
| complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
# object.success callback
# parameter
# Object res
| attribute | type | Introductions |
|---|---|---|
| duration | number | Length of selected audio (in s), returned only when music is playing |
| currentPosition | number | Selected audio playback location (in s), only returned when music is playing |
| status | number | Play state |
| downloadPercent | number | Percentage of audio download progress, only returned when music is playing |
| dataUrl | string | Song data link, returned only when music is playing |
res.status Legal value
| value | Introductions | Minimum version |
|---|---|---|
| 0 | Suspended. | |
| 1 | Play | |
| 2 | No music playing |
# sample code
wx.getBackgroundAudioPlayerState({
success (res) {
const status = res.status
const dataUrl = res.dataUrl
const currentPosition = res.currentPosition
const duration = res.duration
const downloadPercent = res.downloadPercent
}
})