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)
我的手机是一加3T,微信版本是6.5.16版本
qq:467516920
在真机上确实没反应 把src改成网络资源就没问题了
兄弟如果方便留个QQ或微信号,一起交流交流
var filepath = this.data.filepath;
console.log(filepath);
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.src = filepath.tempFilePath;
innerAudioContext.onPlay(() => {
console.log('开始播放')
});
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
});
innerAudioContext.play();
这是我的播放代码
console.log("tempfilepath:"+tempFilePath);
innerAudioContext.src = tempFilePath;
innerAudioContext.play();
请问如何用createInnerAudioContext 播放录制的音频呢,src不是别tempfilepath 报
Failed to set src, the src undefined is invalid.;at pages/myPage page playVoice function
TypeError: Failed to set src, the src undefined is invalid.
我打印的tempfile是wxfile://tmp_*.m4a