takeSnapshot using RTCMultiConnection ® Muaz Khan
HOME © Muaz Khan . @WebRTCWeb . Github . Latest issues . What's New?
New Session:
Local video container |
Remote videos container |
|
"
takeSnapshot
" can be used to take snapshots of a user's first available stream. You can even take snapshot of a specific stream using "stream-id".
Take Snapshot of First Available Stream
// added since v1.4 connection.takeSnapshot
(userid, function(snapshot) { imagePreview.src = snapshot; }); // or // added since v2.2.0 connection.peers
['target-userid'].takeSnapshot(function(snapshot) { imagePreview.src = snapshot; }); // or connection.onstream
= function(event) { if(event.type == 'local') return; // skip local streams setTimeout(function() { connection.peers
[event.userid].takeSnapshot(function(snapshot) { imagePreview.src = snapshot; }); }, 2000); // wait 2 seconds to make sure video is rendered };
Take Snapshot of a Specific Stream
// added since v2.2.0 connection.streams
['streamid'].takeSnapshot(function(snapshot) { imagePreview.src = snapshot; }); // or connection.onstream
= function(event) { if(event.type == 'local') return; // skip local streams setTimeout(function() { connection.streams
[event.streamid].takeSnapshot(function(snapshot) { imagePreview.src = snapshot; }); }, 2000); // wait 2 seconds to make sure video is rendered };