From c28c0437731f567325bdf70d339ef5f722a76901 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 28 Feb 2022 17:54:54 -0600 Subject: [PATCH] Adds support for Janus 1.x --- web/js/MonitorStream.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 27c180998..03917557d 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -561,9 +561,28 @@ async function attachVideo(id) { } }, //onmessage function onremotestream: function(ourstream) { - Janus.debug(" ::: Got a remote track :::"); + Janus.debug(" ::: Got a remote stream :::"); Janus.debug(ourstream); Janus.attachMediaStream(document.getElementById("liveStream" + id), ourstream); + }, + onremotetrack: function(track, mid, on) { + Janus.debug(" ::: Got a remote track :::"); + Janus.debug(track); + if (track.kind ==="audio") { + stream = new MediaStream(); + stream.addTrack(track.clone()); + if (document.getElementById("liveAudio" + id) == null) { + audioElement = document.createElement('audio'); + audioElement.setAttribute("id", "liveAudio" + id); + audioElement.controls = true; + document.getElementById("imageFeed" + id).append(audioElement); + } + Janus.attachMediaStream(document.getElementById("liveAudio" + id), stream); + } else { + stream = new MediaStream(); + stream.addTrack(track.clone()); + Janus.attachMediaStream(document.getElementById("liveStream" + id), stream); + } } }); // janus.attach } //function attachVideo