Fix Duplicate Videos Issues

Muaz Khan edited this page Feb 13, 2017 · 1 revision

This page explains how to fix duplicate cameras/videos issues.

First technique

connection.onstream = function(event) {
    // skip duplicate videos
    if (document.getElementById(event.streamid)) return;

    // give each video a unique ID
    event.mediaElement.id = event.streamid;

    // append video to HTML
    document.body.appendChild(event.mediaElement);
};

Second technique

var listOfVideos = {};

connection.onstream = function(event) {
    // skip duplicate videos
    if (listOfVideos[event.streamid]) return;

    // store "streamid" or "event" object in an array
    // this will help us skip duplicate videos
    // (as you can see in the above if-block)
    listOfVideos[event.streamid] = event.streamid;

    // append video to HTML
    document.body.appendChild(event.mediaElement);
};
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.