访问云端的音频数据,编译是可以播放的,但是到真机播放不了为什么?
发布于 5 年前 作者 guiyingwan 6349 次浏览 来自 问答

真机测试结果

正常编译

-访问云端音频在真机播放不了是什么原因?是不是那个src地址有要求?

onLoad: function (options) {

var that=this;

var id=options.id;

this.audioCtx = wx.createAudioContext(‘myAudio’)

console.log(id)

const db=wx.cloud.database()

db.collection(“introduction”).where({

name:id

}).get({

success: function (res) {

//console.log(res)

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.file[i] = res.data[i];

//console.log(that.data.file[0])

}

that.data.fileid=res.data[0].fileid

that.setData({

file: that.data.file,

fileid: that.data.fileid

}),

//console.log(that.data.fileid)

wx.cloud.downloadFile({

fileID: that.data.fileid,

success: function (res) {

console.log(res.tempFilePath)

that.audioCtx.setSrc(res.tempFilePath)

that.audioCtx.play();

},

fail: function (err) {

console.log(err)

}

})

},

fail: function (err) {

console.log(err)

}

})

1 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

回到顶部