mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-29 15:26:27 +00:00
Fix issue with audio stream
This commit is contained in:
parent
cef4925c66
commit
67e38faac9
@ -477,20 +477,22 @@ class CallWindow extends CustomEvents {
|
|||||||
* @param {boolean} muted True to mute video
|
* @param {boolean} muted True to mute video
|
||||||
* @param {MediaStream} stream Target stream
|
* @param {MediaStream} stream Target stream
|
||||||
*/
|
*/
|
||||||
addVideoStream(peerID, muted, stream) {
|
applyStream(peerID, muted, stream) {
|
||||||
|
|
||||||
// Remove any previous video stream
|
// Remove any previous video stream
|
||||||
if(this.videoEls.has(peerID)) {
|
if(this.videoEls.has(peerID)) {
|
||||||
this.removeVideoElement(peerID)
|
this.removeVideoElement(peerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isVideo = stream.getVideoTracks().length > 0;
|
||||||
|
|
||||||
const videoContainer = createElem2({
|
const videoContainer = createElem2({
|
||||||
appendTo: this.videosArea,
|
appendTo: this.videosArea,
|
||||||
type: "div",
|
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)
|
videoContainer.appendChild(videoEl)
|
||||||
|
|
||||||
videoEl.muted = muted;
|
videoEl.muted = muted;
|
||||||
@ -544,7 +546,7 @@ class CallWindow extends CustomEvents {
|
|||||||
return
|
return
|
||||||
|
|
||||||
// Show user video
|
// Show user video
|
||||||
this.addVideoStream(userID(), true, stream)
|
this.applyStream(userID(), true, stream)
|
||||||
|
|
||||||
this.mainPeer = new SimplePeer({
|
this.mainPeer = new SimplePeer({
|
||||||
initiator: true,
|
initiator: true,
|
||||||
@ -634,7 +636,7 @@ class CallWindow extends CustomEvents {
|
|||||||
peer.on("stream", stream => {
|
peer.on("stream", stream => {
|
||||||
console.log("Got remote peer stream", stream)
|
console.log("Got remote peer stream", stream)
|
||||||
|
|
||||||
this.addVideoStream(peerID, false, stream)
|
this.applyStream(peerID, false, stream)
|
||||||
});
|
});
|
||||||
|
|
||||||
peer.on("close", () => {
|
peer.on("close", () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user