安卓 createInnerAudioContext 播放失败
- 当前 Bug 的表现(可附上截图) 安卓播放失败,ios 与调试工具正常 - 预期表现 所有音频播放正常 - 复现路径 - 提供一个最简复现 Demo [代码]Component({[代码][代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的属性列表[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]properties: {[代码][代码] [代码][代码]audio: {[代码][代码] [代码][代码]type: Object,[代码][代码] [代码][代码]value: {}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]pageLifetimes: {[代码][代码] [代码][代码]hide: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.stop()[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的初始数据[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]playing: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]dur: 0,[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]ready: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]this[代码][代码].innerAudioContext = wx.createInnerAudioContext()[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.src = [代码][代码]'http://tbvideo.ixiaochuan.cn/zyad/07/a0/78ac-c7e0-11e8-8d60-00163e00c638'[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.obeyMuteSwitch = [代码][代码]false[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.volume = 1[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]dur: [代码][代码]this[代码][代码].properties.audio.dur || 0,[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]this[代码][代码].innerAudioContext.onPlay(() => {[代码][代码] [代码][代码]console.log([代码][代码]'play'[代码][代码])[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]this[代码][代码].innerAudioContext.onTimeUpdate((e) => {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]dur: Math.floor([代码][代码]this[代码][代码].innerAudioContext.duration - [代码][代码]this[代码][代码].innerAudioContext.currentTime) > 0 ? Math.floor([代码][代码]this[代码][代码].innerAudioContext.duration - [代码][代码]this[代码][代码].innerAudioContext.currentTime) : 0[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]this[代码][代码].innerAudioContext.onEnded(() => {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]dur: Math.floor([代码][代码]this[代码][代码].properties.audio.dur),[代码][代码] [代码][代码]playing: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]this[代码][代码].innerAudioContext.onWaiting(() => {[代码][代码] [代码][代码]console.log([代码][代码]'正在缓冲...'[代码][代码])[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]this[代码][代码].innerAudioContext.onError((res) => {[代码][代码] [代码][代码]console.log(res.errMsg)[代码][代码] [代码][代码]console.log(res.errCode)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]detached: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.destroy()[代码][代码] [代码][代码]this[代码][代码].innerAudioContext = [代码][代码]null[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的方法列表[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]methods: {[代码][代码] [代码][代码]playAudio: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]const { playing } = [代码][代码]this[代码][代码].data[代码][代码] [代码][代码]if[代码] [代码](playing) {[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.pause()[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]playing: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.play()[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]playing: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]}[代码][代码]})[代码]