通过wx.getRecorderManager()录音的mp3格式文件,调用wx.playVoice无法播放,提示播放失败,请问如何解决?
const recorderManager = wx.getRecorderManager()
recorderManager.onStart(() => {
console.log(‘recorder start’)
})
recorderManager.onResume(() => {
console.log(‘recorder resume’)
})
recorderManager.onPause(() => {
console.log(‘recorder pause’)
})
recorderManager.onStop((res) => {
console.log(‘recorder stop’, res)
const { tempFilePath } = res
wx.playVoice({
filePath: tempFilePath,
fail:function(ret){
console.log(ret)
},
success:function(){
console.log(‘播放成功’)
}
})
})
recorderManager.onFrameRecorded((res) => {
const { frameBuffer } = res
console.log(‘frameBuffer.byteLength’, frameBuffer.byteLength)
})
const options = {
duration: 5000,
sampleRate: 44100,
numberOfChannels: 1,
encodeBitRate: 192000,
format: ‘mp3’,
frameSize: 50
}
recorderManager.start(options)