亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

WeChat applet development documentation / 微信小程序API 音樂播放控制

微信小程序API 音樂播放控制

wx.getBackgroundAudioPlayerState(OBJECT)


獲取音樂播放狀態(tài)

success返回參數(shù)說明:

QQ截圖20170208110749.png

示例代碼:

wx.getBackgroundAudioPlayerState({
    success:function(res){
        var status = res.status;
        var dataUrl = res.dataUrl;
        var currentPosition = res.currentPosition;
        var duration = res.duration;
        var downloadPercent = res.downloadPercent;
    }
})

wx.playBackgroundAudio(OBJECT)


播放音樂,同時只能有一首音樂正在播放。

OBJECT參數(shù)說明

QQ截圖20170208110802.png

示例代碼

wx.playBackgroundAudio({
    dataUrl: '',
    title: '',
    coverImgUrl: ''
})

wx.pauseBackgroundAudio()


暫停播放音樂

示例代碼

wx.pauseBackgroundAudio()

wx.seekBackgroundAudio(OBJECT)


控制音樂播放進(jìn)度

OBJECT參數(shù)說明

參數(shù)類型必填說明
positionNumber音樂位置,單位:秒

示例代碼

wx.seekBackgroundAudio({
    position: 30})

wx.stopBackgroundAudio()


停止播放音樂

示例代碼

wx.stopBackgroundAudio()

wx.onBackgroundAudioPlay(CALLBACK)


監(jiān)聽音樂播放

wx.onBackgroundAudioPause(CALLBACK)


監(jiān)聽音樂暫停

wx.onBackgroundAudioStop(CALLBACK)


監(jiān)聽音樂停止