首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RecordRTC录制取消

RecordRTC录制取消
EN

Stack Overflow用户
提问于 2021-08-03 11:44:27
回答 1查看 105关注 0票数 0

目前,我们可以在angular项目中使用RecordRTC启动和停止录制。但是请帮助我如何添加取消选项才能再次开始录制?

这些是用于开始和取消记录-//开始记录...

代码语言:javascript
复制
 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());
  }
 }
EN

回答 1

Stack Overflow用户

发布于 2021-08-06 18:57:38

您可以使用destroy()来清理所有内容。在您的案例中:

代码语言:javascript
复制
this.recorder.stopRecording(url => {
   this.video.src = url;
   this.recorder.destroy();
   this.recorder = null;
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68635418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档