Skip to content

Commit b98b779

Browse files
committed
fix: ensure switching audio/video properly resets analyser
1 parent 05dcb4c commit b98b779

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

public/main.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,10 @@ audioInputSelect.onchange = videoSelect.onchange = async (e) => {
204204
const audioTrack = stream.getAudioTracks()[0];
205205
const videoTrack = stream.getVideoTracks()[0];
206206

207+
app.selfPlayer.stream = stream;
208+
app.playStream(stream, app.selfPlayer);
207209
app.selfPlayer.analyser = null;
208210

209-
if (e.target.id == 'videoSource') {
210-
app.selfPlayer.stream = stream;
211-
playStream(stream, app.selfPlayer);
212-
}
213-
214211
app.mediasoupClient.producerTransport.handler._pc.getSenders().forEach((s) => {
215212
if (s.track.kind == videoTrack.kind) {
216213
console.log('replacing video!');

public/player.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export class Player {
5454
}
5555

5656
addVideo(element) {
57+
if (this.$video != null) {
58+
this.$video.remove();
59+
}
60+
5761
this.$video = element;
5862
this.$elem.appendChild(element);
5963
}

0 commit comments

Comments
 (0)