一.小知识
1.wx.getBackgroundAudioPlayerState(OBJECT):获取后台音乐播放状态。
[html] view plain copy
<span style="font-family:Comic Sans MS;">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
}
})</span>
2.wx.playBackgroundAudio(OBJECT)
[html] view plain copy
<span style="font-family:Comic Sans MS;font-size:18px;color:#333333;">wx.playBackgroundAudio({
dataUrl: '',
title: '',
coverImgUrl: ''
})</span>
3.wx.pauseBackgroundAudio()暂停播放音乐。
4.wx.seekBackgroundAudio(OBJECT)控制音乐播放进度。
[html] view plain copy
<span style="font-family:Comic Sans MS;">wx.seekBackgroundAudio({
position: 30
})</span>
5.wx.stopBackgroundAudio()停止播放音乐。6.wx.onBackgroundAudioPlay(CALLBACK)监听音乐播放。
7.wx.onBackgroundAudioPause(CALLBACK)监听音乐暂停。
8.wx.onBackgroundAudioStop(CALLBACK)监听音乐停止。
二.案例
[html] view plain copy
<span style="font-family:Comic Sans MS;font-size:18px;color:#333333;"><view class="zn-uploadimg">
<button type="primary" bindtap="listenerButtonPlay">播放</button>
<button type="primary" bindtap="listenerButtonPause">暂停</button>