This object stores all local and remote streams
Use this object to access any stream (local or remote) from any user (based on userid or streamid).
var stream = connection.streamEvents['stream-id'].stream;
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);
// you can pass: 'audio' || 'video' || 'both connection.streamEvents['stream-id'].stream.mute('both'); // or unmute connection.streamEvents['stream-id'].stream.unmute('both');
var firstStreamEvent = connection.streamEvents.selectFirst({ local: true }); firstStreamEvent.stream.getVideoTracks().forEach(function(track) { track.stop(); });
parameter | description | usage |
---|---|---|
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; |
connection.streamEvents.selectAll({ userid: 'remote-userid' }).forEach(function(streamEvent) { streamEvent.stream.getVideoTracks(); });
parameter | description | usage |
---|---|---|
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(); }); |
// 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; });
connection.streamEvents.selectAll().forEach(function(streamEvent) {
streamEvent.stream.getVideoTracks();
});
// 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');
// 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');