From 67e38faac92cc49bd46d957d256bf2b796efbd0b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 13 Apr 2020 09:47:21 +0200 Subject: [PATCH] Fix issue with audio stream --- assets/js/components/calls/window.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/assets/js/components/calls/window.js b/assets/js/components/calls/window.js index 7dbfe3bd..484e2fe4 100644 --- a/assets/js/components/calls/window.js +++ b/assets/js/components/calls/window.js @@ -477,20 +477,22 @@ class CallWindow extends CustomEvents { * @param {boolean} muted True to mute video * @param {MediaStream} stream Target stream */ - addVideoStream(peerID, muted, stream) { + applyStream(peerID, muted, stream) { // Remove any previous video stream if(this.videoEls.has(peerID)) { this.removeVideoElement(peerID) } + const isVideo = stream.getVideoTracks().length > 0; + const videoContainer = createElem2({ appendTo: this.videosArea, type: "div", - class: "video" + class: isVideo ? "video" : undefined }) - const videoEl = document.createElement(stream.getVideoTracks().length > 0 ? "video" : "audio"); + const videoEl = document.createElement(isVideo ? "video" : "audio"); videoContainer.appendChild(videoEl) videoEl.muted = muted; @@ -544,7 +546,7 @@ class CallWindow extends CustomEvents { return // Show user video - this.addVideoStream(userID(), true, stream) + this.applyStream(userID(), true, stream) this.mainPeer = new SimplePeer({ initiator: true, @@ -634,7 +636,7 @@ class CallWindow extends CustomEvents { peer.on("stream", stream => { console.log("Got remote peer stream", stream) - this.addVideoStream(peerID, false, stream) + this.applyStream(peerID, false, stream) }); peer.on("close", () => {