为什么录音临时文件无法播放?刚开始的几次是有效的,后来失效。
API:wx.getRecorderManager() wx.createInnerAudioContext()
const recorderManager = wx.getRecorderManager()
const tempAudio = wx.createInnerAudioContext()
startTap:function(){
var self = this;
this.data.tempPlay = false; //避免播放按钮失效
const option = {
duration:60000, //录音时长10000ms
sampleRate:16000,
numberOfChannels:1,
encodeBitRate:96000,
format:'mp3',
frameSize:50,
}
self.recordingTimer();
//开始录音
recorderManager.start(option);
recorderManager.onStart(
()=>{
console.log('recorder start')
}
);
//错误回调
recorderManager.onError(
(res)=>{
console.log('recorder fail')
}
)
},
endTap:function(){
var self = this;
//console.log("self",self)
this.setData({tempPlay : false}); //避免播放按钮失效
recorderManager.stop();
recorderManager.onStop(
(res)=>{
//临时文件路径
self.tempFilePath = res.tempFilePath;
console.log('thistemp',self.tempFilePath)
console.log('realtemp',res.tempFilePath)
const{tempFilePath} = res;
//文件正常
wx.getFileInfo({
filePath:self.tempFilePath,
success(res){
console.log(res)
}
})
})
},
录音采用MP3格式,刚开始完全ok,但是四五次之后再播放就报错10004,这是为什么?录音要求也没错呀……