父页面调用组件
<recordingVoice :recordingVoiceShow.sync="recordingVoiceShow" :recordingUrl.sync="recordingUrl"></recordingVoice>
<playVoice v-if="(this.recordingUrl == '')?false:true" class="recordingSoundsPath" playType="user" :path.sync="recordingUrl" :recordingTrans.sync="recordingTranslation"></playVoice>
recordingVoice组件部分代码
mounted() {
//录音开始监听
this.recorderManager.onStart(() => {
this.timer = setInterval(() => {
this.times++;
}, 1000);
});
//录音停止后将音频临时文件地址发给父组件
this.recorderManager.onStop(res => {
console.log(res);
clearInterval(this.timer);
//录音结束后将音频临时地址暴露出去
this.$emit('update:recordingUrl', res.tempFilePath);
this.$emit('update:recordingVoiceShow', false);
});
}
playVoice组件部分代码
watch: {
path: {
immediate: true,
handler: function(newVal) {
if (newVal) {
console.log(newVal)
this.voicePath = newVal;
this.innerAudioContext.src = newVal;
//音频时长
this.innerAudioContext.onCanplay(() => {
console.log(this.innerAudioContext.duration);
this.allTime = 0;
this.allTime = this.timeChange(this.innerAudioContext.duration.toFixed(0));
});
}
}
}
},
2 个回复
1***@163.com
2023年了,这个问题还有
l***@gmail.com (作者)
有官方的人在吗?这不算bug?还是你们无法复现?给个回复啊