录音结束后,调用录音文件的临时路径不能进行试听,如何可以进行录音文件试听或者用户的试听确认?
官方录音示例,加入了试听代码,播放不了
recorderManager.onStop((res) => {
console.log(‘recorder stop’, res)
const { tempFilePath } = res;
console.log(tempFilePath)
wx.playVoice({
filePath: tempFilePath,
complete: function () {
console.log(“播放成功”)
}
})
})
采用最新的录音api
const recorderManager = wx.getRecorderManager();
const options = {
duration: 5000,
sampleRate: 44100,
numberOfChannels: 1,
encodeBitRate: 192000,
format: ‘mp3’,
frameSize: 50
};
recorderManager.start(options);
recorderManager.onStop((res) => {
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = tempFilePath;
});