From 980d6822d0e6e338fe429bb37f23a58dd9d194f4 Mon Sep 17 00:00:00 2001 From: EpicKiwi Date: Thu, 21 Sep 2023 12:16:12 +0200 Subject: [PATCH] support audio --- static/js/grab-canvas.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/static/js/grab-canvas.js b/static/js/grab-canvas.js index 3827ccf..3fe29b9 100644 --- a/static/js/grab-canvas.js +++ b/static/js/grab-canvas.js @@ -46,6 +46,16 @@ throw new Error("Element don't habe video track") } + const canvasAudioTracks = canvasStream.getAudioTracks() + if(canvasAudioTracks.length > 0){ + const AudioContext = window.AudioContext || window.webkitAudioContext; + if(AudioContext){ + const audioContext = new AudioContext(); + audioContext.createMediaStreamTrackSource(canvasAudioTracks[0]) + .connect(audioContext.destination) + } + } + const offer = await conn.createOffer(); await conn.setLocalDescription(offer);