收听 chrome 底部停止共享按钮的点击事件

时间:2021-06-03 07:49:27

标签: angular google-chrome

有没有办法可以收听使用 angular 共享屏幕时出现在 chrome 底部的停止共享按钮的点击事件
stop sharing button

点击停止分享需要调用的方法

 handleStopRecording() {
    this.recordOption.isStart = !this.recordOption.isStart;
    this.showWebcam = false;
    if (
      this.requestType === "screenAndCamera" ||
      this.requestType === "audioAndScreen"
    ) {
      this.handleStopRecordingOption().then(() => {
        this.handleUploadBlob();
        // this.subscribeVideoObserver();
      });
    }
    if (this.requestType === "cameraAndAudio") {
      this.handleStopCameraRecording().then(() => {
        this.handleUploadBlob();
        // this.subscribeVideoObserver();
      });
    }

handlestopRecordingOption

  handleStopRecordingOption = () => {
    return new Promise((resolve, reject) => {
      this.recorder.stopRecording(() => {
        RecordRTC.getSeekableBlob(this.recorder.getBlob(), (seekableBlob) => {
          this.videoData.videoLength =
            (new Date().getTime() - this.dateStarted) / 1000;
          var blob = seekableBlob;
          this.render.setAttribute(
            this.downloadLinkRef.nativeElement,
            "href",
            URL.createObjectURL(blob)
          );
          this.videoData.videoName = `${moment().format(
            "MM-DD-YYYY__HH-mm-ss"
          )}_recorderVideo.mkv`;
          this.videoData.videoFile = new File([blob], this.videoData.videoName);
          this.recordOption.isDownloadAvailable = true;
          this.render.setProperty(this.video.nativeElement, "muted", true);
          this.render.setProperty(this.video.nativeElement, "srcObject", null);
          this.render.setProperty(
            this.video.nativeElement,
            "src",
            `${URL.createObjectURL(blob)}#t=${this.videoData.videoLength - 2},${
              this.videoData.videoLength
            }`
          );
          this.screen.getTracks().forEach((track) => track.stop());
          this.camera.getTracks().forEach((track) => track.stop());
          resolve(true);
        });
      });
    });
  };

0 个答案:

没有答案