wx.createInnerAudioContext()在微信开发者工具和苹果手机上可以播放,在安卓手机上不能播放。
const innerAudioContext = wx.createInnerAudioContext()
//音频播放
audio_click: function (e) {
var that = this;
var index = e.currentTarget.dataset.id;
var src = e.currentTarget.dataset.src;
var audioId = that.data.totalArr[index].name;
audioId = innerAudioContext;
audioId.volume = 1;
audioId.obeyMuteSwitch = false;
audioId.autoplay = true;
if (that.data.audio_index != null && that.data.audio_index != index){
that.data.totalArr[that.data.audio_index].isPlay = false;
}
if (that.data.totalArr[index].isPlay == false) {
audioId.src = src;
audioId.play();
that.data.totalArr[index].isPlay = true;
that.setData({
totalArr: that.data.totalArr
})
} else if (that.data.totalArr[index].isPlay == true) {
audioId.src = null;
that.data.totalArr[index].isPlay = false;
that.setData({
totalArr: that.data.totalArr,
audio_index: index
})
audioId.stop();
}
audioId.onEnded(() => {
that.data.totalArr[index].isPlay = false;
that.setData({
totalArr: that.data.totalArr,
audio_index: index
})
audioId.stop();
audioId.src = null;
})
audioId.onPlay(() => {
var total = parseInt(audioId.duration);
var minute = parseInt(total / 60);
if (minute < 10) {
minute = '0' + minute;
}
var second = total % 60;
if (second < 10) {
second = '0' + second;
}
total = minute + ":" + second;
that.data.totalArr[index].slider_max = total;
that.setData({
totalArr: that.data.totalArr
})
audioId.onTimeUpdate(() =>{
console.log(audioId.currentTime)
})
})
console.log(that.data.totalArr[0])
console.log(that.data.totalArr[1])
},
音频这个问题太多了 希望官方可以尽快完善
errCode:67,err:decode audio fail 10001
你好,其实像这种无法播放的事件,可以加个音频播放错误事件,打印下错误回调信息查看下,针对问题来排查原因的
看到了错误回调信息,但还是定位不到哪里有问题
后来解决了吗? 我这边是开发工具和安卓可以播放 但是苹果机都不可以播放
您那边音频问题解决了么
解决了 文件名字不能用中文的 之前的音频名字有的是中文格式的 改过来就好了