求解 用wx.playBackgroundAudio(OBJECT)能播放的外链用 wx.getBackgroundAudioManager()播放不了换成示例链接可以用。
代码如下:
listenerButtonPlay: function () {
var that = this
const sing = wx.getBackgroundAudioManager()
sing.title = this.data.musicname
sing.coverImgUrl = this.data.musicphoto
sing.src = ‘http://mp3.qqmusic.cc/yq/107187243.mp3’
此处外链音乐播放失败
sing.onPlay(() => {
console.log(“音乐播放开始”);
})
sing.onEnded(() => {
console.log(“音乐播放结束”);
})
sing.onTimeUpdate(function () {
var duration = Math.ceil(sing.duration * 1000000)
var currentTime = Math.ceil(sing.currentTime * 1000000)
var musicpercent = currentTime/duration*100
that.setData({ duration, currentTime, musicpercent })
})
that.setData({ swich: true, musicplay: ‘listenerButtonPause’,})
},