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