Skip to content

Commit

Permalink
Fix bug where switching media caused media in subsequent calls to fail (
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr authored Jun 20, 2023
1 parent 9c6d5a6 commit ca00094
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/webrtc/mediaHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,19 @@ export class MediaHandler extends TypedEventEmitter<
this.emit(MediaHandlerEvent.LocalStreamsChanged);

if (this.localUserMediaStream === mediaStream) {
// if we have this stream cahced, remove it, because we've stopped it
this.localUserMediaStream = undefined;
} else {
// If it's not the same stream. remove any tracks from the cached stream that
// we have just stopped, and if we do stop any, call the same method on the
// cached stream too in order to stop all its tracks (in case they are different)
// and un-cache it.
for (const track of mediaStream.getTracks()) {
if (this.localUserMediaStream?.getTrackById(track.id)) {
this.stopUserMediaStream(this.localUserMediaStream);
break;
}
}
}
}

Expand Down

0 comments on commit ca00094

Please sign in to comment.