RTCMultiConnection Docs

RTCMultiConnection API Reference / "takeSnapshot" method

"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". Try a LIVE demo!

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
};

Want to ask a Question?

You can include your email for private conversation!

Latest Updates