WebRTC-Experiment icon indicating copy to clipboard operation
WebRTC-Experiment copied to clipboard

Auto record a tab.

Open collisiondetection opened this issue 4 years ago • 1 comments

Is there a way to auto record a tab without the users intervention.

We would like to make sure a tab is always recorded and not rely on user input.

collisiondetection avatar Oct 21 '19 03:10 collisiondetection

If you want to auto record then you can use recordRTC when your connection is established. for example:

var connection = new RTCMultiConnection();
 var video = document.querySelector('#video')
// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
 connection.session = {
           audio: true,
           video: true,
           oneway: true
          };
connection.mediaConstraints = {
         video: true,
         audio: true
       };
connection.open('coach-stream')
                            
                        
 connection.sdpConstraints.mandatory = {
          OfferToReceiveAudio: false,
          OfferToReceiveVideo: false
        };
connection.onstream=function(event){
                            if( event.type === 'local' ){
                                video.addEventListener("pause", function(){
                                    connection.streamEvents.selectFirst({local: true}).stream.mute();
                                });
                                
                                video.addEventListener("play", function(){
                                    connection.streamEvents.selectFirst({local: true}).stream.unmute();
                                });
                        }                                           
video.srcObject = event.stream
 var recorder = RecordRTC(event.stream, {type:'video'})
recorder.startRecording();

hope this helps.

yodaljit avatar Aug 27 '20 06:08 yodaljit