为什么小程序(新接口wx.getRecorderManager())录制的音频上传之后就不能(wx.createInnerAudioContext())播放了
//微信小程序新录音接口,录出来的是aac或者mp3,这里要录成mp3
const mp3Recorder = wx.getRecorderManager()
const mp3RecoderOptions = {
duration: 60000,
sampleRate: 16000,
numberOfChannels: 1,
encodeBitRate: 48000,
format: ‘mp3’,
//frameSize: 50
}
//本接口是 wx.createAudioContext 升级版。
const innerAudioContext = wx.createInnerAudioContext();
在onload事件里:
mp3Recorder.onStart(() => {
console.log(‘mp3Recorder.onStart() recordOrderId:’ + that.data.recordOrderId);
});
mp3Recorder.onStop(function (res) {
//…省略将音频文件上传到服务器代码
});
在wxml页面里使用audio控件播放,会提示:
VM3259:2 Uncaught (in promise) NotSupportedError: The element has no supported sources.
自己加一个按钮用于测试点击播放也不行:
//开始播放:
audioPlay:function(event){
var currentControl = event.target;
var url = currentControl.dataset.url;
console.log(url);
innerAudioContext.src = url;
innerAudioContext.onPlay(() => {
console.log(‘开始播放’);
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
})
innerAudioContext.play();
}
难道新接口也需要自己去做base64解码后再存储到服务器?