Skip to content

Commit

Permalink
fix: ensure switching audio/video properly resets analyser
Browse files Browse the repository at this point in the history
  • Loading branch information
iamDecode committed Mar 13, 2021
1 parent 05dcb4c commit b98b779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 2 additions & 5 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,10 @@ audioInputSelect.onchange = videoSelect.onchange = async (e) => {
const audioTrack = stream.getAudioTracks()[0];
const videoTrack = stream.getVideoTracks()[0];

app.selfPlayer.stream = stream;
app.playStream(stream, app.selfPlayer);
app.selfPlayer.analyser = null;

if (e.target.id == 'videoSource') {
app.selfPlayer.stream = stream;
playStream(stream, app.selfPlayer);
}

app.mediasoupClient.producerTransport.handler._pc.getSenders().forEach((s) => {
if (s.track.kind == videoTrack.kind) {
console.log('replacing video!');
Expand Down
4 changes: 4 additions & 0 deletions public/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class Player {
}

addVideo(element) {
if (this.$video != null) {
this.$video.remove();
}

this.$video = element;
this.$elem.appendChild(element);
}
Expand Down

0 comments on commit b98b779

Please sign in to comment.