第一次打开APP的时候不进入recorderManager1.onStart,然后进入APP后再点进入这个页面的时候能执行recorderManager1.onStart,但是this.result的值不改变。是什么原因呀?
<template>
<view>
<button @tap="playVoice">播放录音</button>
{{result}}
</view>
</template>
<script>
const recorderManager1 = uni.getRecorderManager();
const innerAudioContext1 = uni.createInnerAudioContext();
export default {
data() {
return {
result: false,
text: 'uni-app',
voicePath: '../../static/62497238-e924-401a-b1d7-e20c8f9ef8b9.wav'
}
},
onLoad() {
this.playVoice();
},
methods: {
playVoice() {
innerAudioContext1.src = this.voicePath;
innerAudioContext1.autoplay = true;
console.log('播放录音');
innerAudioContext1.play();
innerAudioContext1.onPlay(() => {
console.log("play")
})
innerAudioContext1.onEnded(() => {
console.log("onEnded")
console.log('开始录音');
recorderManager1.start();
// 监听录音开始
recorderManager1.onStart(() => {
console.log('recorder2 start')
this.result = true;
})
});
}
}
}
</script>
<style>
</style>
1 个回复
7***@qq.com
我也遇到这个问题了