用innerAudioContext 播放录制的音频真机报错
发布于 6 年前 作者 ping16 11442 次浏览 来自 问答

android无任何反映 不报错 不播放

ios :报错 operateAudio:fail audioinstance is palying or waiting

代码

var tempFilePath;

const innerAudioContext = wx.createInnerAudioContext();

innerAudioContext.onPlay(() => {

console.log(‘开始播放’)

});

innerAudioContext.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

});

const recorderManager = wx.getRecorderManager();

const option = {

duration: 100000,

sampleRate: 44100,

numberOfChannels: 1,

encodeBitRate: 192000,

format: ‘aac’

//frameSize: 50

}

recorderManager.onStart(() => {

console.info(‘recorder start’)

})

recorderManager.onResume(() => {

console.info(‘recorder resume’)

})

recorderManager.onPause(() => {

console.log(‘recorder pause’)

})

recorderManager.onStop((res) => {

console.info(‘recorder stop’);

tempFilePath = res.tempFilePath;

console.info(tempFilePath,res);

})

Page({

startRecord:function(e){

recorderManager.start(option);

}

,

stopRecord: function (e) {

recorderManager.stop();

},

playVoice: function (e) {

console.info(tempFilePath);

innerAudioContext.src=tempFilePath;

console.info(“start play”)

innerAudioContext.play();

console.info(“end”)

}

})

4 回复

innerAudioContext.autoplay = true;

设置autoplay 为ture试下

innerAudioContext 的 onError 不能像 backgroundManager 的onError那么强大,很多错误都不会回调的

回到顶部