May 18, 2021 WeChat Mini Program Development Document
Starting with base library 1.2.0, this interface is out of maintenance, using wx.getBackgroundAudioManager instead
Gets the background music playback status.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
duration | number | The length of the selected audio (in s) and returns only when the music is playing |
currentPosition | number | The selected audio playback location (in s) and returns only when the music is playing |
status | number | Play status |
downloadPercent | number | The percentage of audio download progress that is returned only when the music is playing |
dataUrl | string | Song data link, returned only when the music is playing |
The legal value of res.status
Value | Description | The lowest version |
---|---|---|
0 | Paused | |
1 | Played | |
2 | No music is playing |
wx.getBackgroundAudioPlayerState({
success (res) {
const status = res.status
const dataUrl = res.dataUrl
const currentPosition = res.currentPosition
const duration = res.duration
const downloadPercent = res.downloadPercent
}
})