Skip to content

Commit e8df347

Browse files
committed
webrtcclient: use onaddstream
1 parent 14b1304 commit e8df347

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

webrtcclient.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ WebRTCClient.prototype.setLocalDescription = function(desc) {
188188

189189
pc.setLocalDescription(new RTCSessionDescription(desc))
190190
.catch(err => {
191-
callback(err);
191+
callback(err);cd
192192
});
193193
}, desc);
194194
};
@@ -198,11 +198,15 @@ WebRTCClient.prototype.setLocalDescription = function(desc) {
198198
WebRTCClient.prototype.setRemoteDescription = function(desc) {
199199
return this.driver.executeAsyncScript(function(desc) {
200200
var callback = arguments[arguments.length - 1];
201-
202-
pc.onaddstream = function(event) {
201+
pc.ontrack = function (event) {
202+
var id = event.streams[0].id;
203+
if (document.getElementById('video-' + id)) {
204+
return;
205+
}
203206
var video = document.createElement('video');
207+
video.id = 'video-' + id;
204208
video.autoplay = true;
205-
video.srcObject = event.stream;
209+
video.srcObject = event.streams[0];
206210
document.body.appendChild(video);
207211
};
208212
pc.setRemoteDescription(new RTCSessionDescription(desc))

0 commit comments

Comments
 (0)