设备:iPhone 5s
系统: iOS 10.1
var voiceUrl = "http://xxxxxxx/xxxx.silk";
wx.downloadFile({
url: voiceUrl,
header: {},
success: function(res) {
wx.playVoice({
filePath: res.tempFilePath,
success: function (res) { },
fail: function (res) { },
complete: function (res) {
console.log(res);
},
})
},
fail: function(res) {},
complete: function(res) {
console.log(res);
},
})
播放的是silk文件。。。。。
代码也没错吧。。。。。
真机开调试,发现死活没调用wx:playVoice这个接口,何解!
调用:
wx.playBackgroundAudio({
dataUrl: voiceUrl,
title: ‘’,
coverImgUrl: ‘’,
success: function (res) { },
fail: function (res) { },
complete: function (res) {
console.log(res);
},
})
可以播了。。。。
但不支持本地播放么???只能播在线音频…
不能了,我这样写的:
wx.downloadFile({
url: voiceUrl,
header: {},
success: function(res) {
wx.playBackgroundAudio({
dataUrl: res.tempFilePath,
title: ‘’,
coverImgUrl: ‘’,
success: function (res) { },
fail: function (res) { },
complete: function (res) {
console.log(res);
},
})
},
fail: function(res) {},
complete: function(res) {
console.log(res);
},
})
真机调试显示:
{errMsg: “playBackgroundAudio: fail dataUrl or webUrl or lowbandUrl must http or https stream”}