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")
}
....
})
innerAudioContext 的 onError 不能像 backgroundManager 的onError那么强大,很多错误都不会回调的
innerAudioContext.autoplay = true;
设置autoplay 为ture试下
我也是
我也是