streamEvents | RTCMultiConnection

Use this object to access any stream (local or remote) from any user (based on userid or streamid).

Get a stream using "streamid"

var stream = connection.streamEvents['stream-id'].stream;

Get all streams by userid

var allStreams = [];

Object.keys(connection.streamEvents).forEach(function(streamid) {
    var event = connection.streamEvents[streamid];

    if (event.userid === 'your-preferred-userid') {
        allStreams.push(event.stream);
    }
});

alert(allStreams.length);

Mute or UnMute a stream by streamid

// you can pass: 'audio' || 'video' || 'both
connection.streamEvents['stream-id'].stream.mute('both');

// or unmute
connection.streamEvents['stream-id'].stream.unmute('both');

Use "selectFirst" to select first available stream

var firstStreamEvent = connection.streamEvents.selectFirst({
    local: true
});

firstStreamEvent.stream.getVideoTracks().forEach(function(track) {
    track.stop();
});
parameterdescriptionusage
local:true get your first local stream
var firstLocalStream = connection.streamEvents.selectFirst({
    local: true
}).stream;
isVideo:true get first local or remote video stream (camera-only stream)
var firstLocalCameraStream = connection.streamEvents.selectFirst({
    local: true,
    isVideo: true
}).stream;
isAudio:true get first local or remote audio stream (microphone-only stream)
var firstLocalMicrophoneStream = connection.streamEvents.selectFirst({
    local: true,
    isAudio: true
}).stream;
remote:true get first remote stream
var firstRemoteStream = connection.streamEvents.selectFirst({
    remote: true
}).stream;
userid:string get first stream by a userid
var selectedUserFirstStream = connection.streamEvents.selectFirst({
    userid: 'selected-user-id'
}).stream;
isScreen:true get first screen stream
var firstScreenStream = connection.streamEvents.selectFirst({
    isScreen: true
}).stream;

Use "selectAll" to select all streams

connection.streamEvents.selectAll({
    userid: 'remote-userid'
}).forEach(function(streamEvent) {
    streamEvent.stream.getVideoTracks();
});
parameterdescriptionusage
local:true get all local streams
connection.streamEvents.selectAll({
    local: true
}).forEach(function(localStreamEvent) {
    localStreamEvent.stream.getVideoTracks();
});
isVideo:true get all local or remote video streams (camera-only streams)
connection.streamEvents.selectAll({
    local: true,
    isVideo: true
}).forEach(function(localVideoStreamEvent) {
    localVideoStreamEvent.stream.getVideoTracks();
});
isAudio:true get all local or remote audio streams (microphone-only streams)
connection.streamEvents.selectAll({
    local: true,
    isAudio: true
}).forEach(function(localAudioStreamEvent) {
    localAudioStreamEvent.stream.getVideoTracks();
});
remote:true get all remote streams
connection.streamEvents.selectAll({
    remote: true
}).forEach(function(remoteStreamEvent) {
    remoteStreamEvent.stream.getVideoTracks();
});
userid:string get all streams by a userid
connection.streamEvents.selectAll({
    userid: 'selected-user-id'
}).forEach(function(remoteStreamEvent) {
    remoteStreamEvent.stream.getVideoTracks();
});
isScreen:true get all screen streams
connection.streamEvents.selectAll({
    isScreen: true
}).forEach(function(screenEvent) {
    screenEvent.stream.getVideoTracks();
});

Use "takeSnapshot" to get video snapshots

// get first local video's snpashot
connection.streamEvents.selectFirst({
    local: true
}).takeSnapshot(function(snapshotImage, blob) {
    yourImage.src = snapshotImage;
});


// get all remote videos' snapshots
connection.streamEvents.selectAll({
    remote: true
}).takeSnapshot(function(snapshotImage, blob) {
    yourImage.src = snapshotImage;
});

Use "forEach" to iterate over stream events

connection.streamEvents.selectAll().forEach(function(streamEvent) {
    streamEvent.stream.getVideoTracks();
});

Use "mute" to disable your outgoing stream

// mute first local stream
connection.streamEvents.selectFirst('local').mute();

// mute all local streams
connection.streamEvents.selectAll('local').mute();

// mute first local screen stream
connection.streamEvents.selectFirst({
    isScreen: true,
    local: true
}).mute();

// mute first local stream's audio tracks (only audio tracks)
connection.streamEvents.selectFirst().mute('audio');

Use "unmute" to disable your outgoing stream

// unmute first local stream
connection.streamEvents.selectFirst('local').unmute();

// unmute all local streams
connection.streamEvents.selectAll('local').unmute();

// unmute first local screen stream
connection.streamEvents.selectFirst({
    isScreen: true,
    local: true
}).unmute();

// unmute first local stream's audio tracks (only audio tracks)
connection.streamEvents.selectFirst().unmute('audio');