2017-08-23 3 views
0

Ich versuche, jede neue Sitzung/Benutzer zu RTCMultiConnection hinzugefügt.
ich die folgende Demo url bin mit in Anwendung https://rtcmulticonnection.herokuapp.com/demos/Audio+Video+TextChat+FileSharing.htmlstartRecording funktioniert nicht mit RecordRTC mit RTCMultiConnection

Jetzt habe ich den folgenden CDN Verweis auf den Code hinzugefügt. https://cdn.webrtc-experiment.com/RecordRTC.js

und das ist der Code, mit dem ich arbeite, aber connection.streams[event.streamid].startRecording(); funktioniert nicht.

// ..................RTCMultiConnection Code............. // ...................................................... var connection = new RTCMultiConnection(); var btnStopRec = document.getElementById("btnStopRecording"); connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/'; connection.enableFileSharing = true; connection.session = { audio: true, video: true, data: true, }; connection.sdpConstraints.mandatory = { OfferToReceiveAudio: true, OfferToReceiveVideo: true, }; connection.onstream = function (event) { document.body.appendChild(event.mediaElement); console.log("stream recording starts") connection.streams[event.streamid].startRecording(); console.log("stream recording started") }

Antwort

1

enthalten wir alle möglichen Situationen in einem einzigen Code-Schnipsel, unten. Bitte nehmen Sie nur den Code, den Sie brauchen:

// global object that contains multiple recorders 
var recorders = {}; 

// auto start recorder as soon as stream starts/begins 
connection.onstream = function(event) { 
    document.body.appendChild(event.mediaElement); 

    recorders[event.streamid] = RecordRTC(event.stream, { 
     type: 'video' 
    }); 

    recorders[event.streamid].startRecording(); 
}; 

// auto stop recorder as soon as stream stops/ends 
connection.onstreamended = function(event) { 
    if (recorders[event.streamid]) { 
     recorders[event.streamid].stopRecording(function() { 
      var blob = recorders[event.streamid].getBlob(); 
      var url = URL.createObjectURL(blob); 
      window.open(url); 

      delete recorders[streamid]; // clear 
     }); 
    } 

    if (event.mediaElement.parentNode) { 
     event.mediaElement.parentNode.removeChild(event.mediaElement); 
    } 
}; 

// stop single recorder 
document.getElementById('manually-stop-single-recording').onclick = function() { 
    var streamid = prompt('Enter streamid'); 
    recorders[streamid].stopRecording(function() { 
     var blob = recorders[streamid].getBlob(); 
     var url = URL.createObjectURL(blob); 
     window.open(url); 

     delete recorders[streamid]; // clear 
    }); 
}; 

// stop all recorders 
document.getElementById('manually-stop-all-recordings').onclick = function() { 
    Object.keys(recorders).forEach(function(streamid) { 
     recorders[streamid].stopRecording(function() { 
      var blob = recorders[streamid].getBlob(); 
      var url = URL.createObjectURL(blob); 
      window.open(url); 

      delete recorders[streamid]; // clear 
     }); 
    }); 
}; 

// record outside onstream event 
// i.e. start recording anytime manually 
document.getElementById('record-stream-outside-the-onstream-event').onclick = function() { 
    var streamid = prompt('Enter streamid'); 
    var stream = connection.streamEvents[streamid].stream; 

    recorders[streamid] = RecordRTC(stream, { 
     type: 'video' 
    }); 

    recorders[streamid].startRecording(); 
}; 
+0

danke bro ... tusee großes Heu ... :) –

Verwandte Themen