Skip to content

Commit

Permalink
examples: dont fiddle with srcObject if already set
Browse files Browse the repository at this point in the history
dont attempt to set srcObject if it is already set in
the examples.

This covers two cases:
* ontrack with an audio and a video track
* early media (see discussion in #1128)
  • Loading branch information
fippo committed Apr 18, 2017
1 parent fb23e75 commit 8e99a96
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions webrtc.html
Expand Up @@ -10954,9 +10954,9 @@ <h3>Simple Peer-to-peer Example</h3>
.catch(logError);
};

// once remote video track arrives, show it in the remote video element
// once remote track arrives, show it in the remote video element
pc.ontrack = function (evt) {
if (evt.track.kind === "video")
if (!remoteView.srcObject)
remoteView.srcObject = evt.streams[0];
};

Expand Down Expand Up @@ -11049,7 +11049,7 @@ <h3>Advanced Peer-to-peer Example with Warm-up</h3>
.catch(logError);
};

// once remote video track arrives, show it in the remote video element
// once remote track arrives, show it in the remote video element
pc.ontrack = function (evt) {
if (evt.track.kind === "audio") {
if (answerer) {
Expand All @@ -11067,8 +11067,9 @@ <h3>Advanced Peer-to-peer Example with Warm-up</h3>
video.sender.replaceTrack(videoSendTrack);
}
}
remoteView.srcObject = evt.streams[0];
}
if (!remoteView.srcObject)
remoteView.srcObject = evt.streams[0];
};

// get a local stream, show it in a self-view and add it to be sent
Expand Down

0 comments on commit 8e99a96

Please sign in to comment.