muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.47k stars 1.75k forks source link

error TS2304: Cannot find name 'getSeekableBlob'. - in Angular framework #601

Open alaaharb321 opened 4 years ago

alaaharb321 commented 4 years ago

I'm using recoredRTC in Angular framework .. so when I tried to use the getSeekableBlob() and invokeSaveAsDialog() function on my code the following error pops up.

ERROR in src/app/components/record-rtc/record-rtc.component.ts(120,7): error TS2304: Cannot find name 'getSeekableBlob'. src/app/components/record-rtc/record-rtc.component.ts(122,10): error TS2304: Cannot find name 'invokeSaveAsDialog'.

Note that I have installed recordRTC using npm on my project and then I imported it as follows import * as RecordRTC from 'recordrtc';

export class RecordRtcComponent implements AfterViewInit { private stream: MediaStream; private recordRTC: any; @ViewChild('video', { static: false }) video: any

processVideo(audioVideoWebMURL) {

  let timestamp = (new Date()).valueOf();
  this.dt = this.datePipe.transform(timestamp, 'dd-MMM-yyyy_hh-mm-ss');
  //Filename of the video
  this.fileName = 'Video_' + this.dt + '.mp4';

  let video: HTMLVideoElement = this.video.nativeElement;
  let recordRTC = this.recordRTC;
  video.src = audioVideoWebMURL;
  this.toggleControls();
  this.recordedBlob = recordRTC.getBlob();

  recordRTC.getDataURL(function (dataURL) { });

  console.log(recordRTC);
  //To show video duration
  getSeekableBlob(recordRTC.getBlob(), function(seekableBlob) {
    video.src = URL.createObjectURL(seekableBlob);
     invokeSaveAsDialog(seekableBlob, 'seekable-recordrtc.webm');
  });

}

stopRecording() { // We use the mediaStream to relase the web cam and microphone let recordRTC = this.recordRTC; // Obtain the recorded video URL and provide it as an argument to "processVideo()" recordRTC.stopRecording(this.processVideo.bind(this)); let stream = this.stream;

stream.getVideoTracks().forEach(track => track.stop());

}

}

Please advice if there is anything else I need to import or how I should use these function correctly on angular

alaaharb321 commented 4 years ago

I solved it by referring to this Fixed #529 use this: require('recordrtc').getSeekableBlob; Thanks...