目前,我们可以在angular项目中使用RecordRTC启动和停止录制。但是请帮助我如何添加取消选项才能再次开始录制?
这些是用于开始和取消记录-//开始记录...
async startRecording() {
if (this.stream == null && this.recorder == null) {
try {
this.stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
});
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(stream => {
this.recorder = RecordRTC(stream, {
mimeType: 'video/webm'
});
this.recorder.startRecording();
this.video.srcObject = stream;
this.video.muted = true;
this.video.autoplay = true;
})
.catch(ex => {
});
} catch (ex) {
this.errorMessage = true;
}
}
}
//stop recording...
stopRecording() {
this.video.srcObject = null;
this.video.muted = false;
this.video.autoplay = false;
if (this.stream != null && this.recorder != null) {
this.recorder.stopRecording(url => {
this.video.src = url;
});
this.stream.getTracks().forEach(track => track.stop());
}
}发布于 2021-08-06 18:57:38
您可以使用destroy()来清理所有内容。在您的案例中:
this.recorder.stopRecording(url => {
this.video.src = url;
this.recorder.destroy();
this.recorder = null;
});https://stackoverflow.com/questions/68635418
复制相似问题