File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,19 @@ export class MediaHandler extends TypedEventEmitter<
334334 this . emit ( MediaHandlerEvent . LocalStreamsChanged ) ;
335335
336336 if ( this . localUserMediaStream === mediaStream ) {
337+ // if we have this stream cahced, remove it, because we've stopped it
337338 this . localUserMediaStream = undefined ;
339+ } else {
340+ // If it's not the same stream. remove any tracks from the cached stream that
341+ // we have just stopped, and if we do stop any, call the same method on the
342+ // cached stream too in order to stop all its tracks (in case they are different)
343+ // and un-cache it.
344+ for ( const track of mediaStream . getTracks ( ) ) {
345+ if ( this . localUserMediaStream ?. getTrackById ( track . id ) ) {
346+ this . stopUserMediaStream ( this . localUserMediaStream ) ;
347+ break ;
348+ }
349+ }
338350 }
339351 }
340352
You can’t perform that action at this time.
0 commit comments