RTCMultiConnection Docs

RTCMultiConnection API Reference / "onstreamid" event

"onstreamid" event is fired only for all-remote media streams. It allows you get clue of incoming remote stream. You can show a progress indicator to the user or a blank-video box so user knows he is about to receive a video.
// on getting remote stream's clue
connection.onstreamid = function (e) {
    var mediaElement = document.createElement(e.isAudio ? 'audio' : 'video');
    mediaElement.controls = true;
    mediaElement.poster = connection.resources.muted;
    mediaElement.id = e.streamid;
    connection.body.appendChild(mediaElement);
};

// on getting local or remote media stream
connection.onstream = function (e) {
    if (e.type == 'local') {
        connection.body.appendChild(e.mediaElement);
        return;
    }

    var mediaElement = document.getElementById(e.streamid);
    if (!mediaElement) return;
    mediaElement.src = e.blobURL;
    mediaElement.play();
};

// when remote user closed the stream
connection.onstreamended = function (e) {
    if (e.type == 'local') {
        e.mediaElement.parentNode.removeChild(e.mediaElement);
        return;
    }

    var mediaElement = document.getElementById(e.streamid);
    if (!mediaElement) return;
    mediaElement.parentNode.removeChild(mediaElement);
};

Want to ask a Question?

You can include your email for private conversation!

Latest Updates