const recorderManager = uni.getRecorderManager();
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
export default {
data() {
return {
text: 'uni-app',
voicePath: ''
}
},
onLoad() {
let self = this;
recorderManager.onStop(function (res) {
console.log('recorder stop' + JSON.stringify(res));
self.voicePath = res.tempFilePath;
});
},
methods: {
startRecord() {
console.log('开始录音');
recorderManager.start();
},
endRecord() {
console.log('录音结束');
recorderManager.stop();
},
playVoice() {
console.log('播放录音');
if (this.voicePath) {
innerAudioContext.src = this.voicePath;
innerAudioContext.play();
}
}
}
}
982260355 (作者)
hello uni-app没有报错,经过比对,官方示例中没有传入format: 'mp3',hello uni-app中传入了。添加后BUG消失,但是官方文档中,format是非必填项,并且默认值为mp3。
2022-03-17 11:26
DCloud_UNI_Anne
回复 9***@qq.com: hello uni-app示例中去掉format配置项是否正常?
2022-03-17 11:35
982260355 (作者)
回复 DCloud_UNI_Anne: hello uni-app示例中 recorderManager.start({});不报错 recorderManager.start();报错
2022-03-17 12:43
982260355 (作者)
回复 DCloud_UNI_Anne: 虽然可以绕过去,但是不打算解决吗,毕竟文档里面就没有传任何东西哦。
2022-03-18 14:16
982260355 (作者)
回复 DCloud_UNI_Anne: 另外app端,会适配defineAsyncComponent 异步组件吗?现在只能h5用
2022-03-18 14:17