问题
I try to stop the browser webcam permissions indicator by using track.stop()
like this:
myLocalStream.getTracks().forEach(track => {
track.stop();
});
In most cases this works fine. But if during the session I have switched between different cameras by using replaceTrack()
it will not work. The browser still shows a running webcam. The code for switching between tracks looks like this:
pc.getSenders().map(sender => {
sender.replaceTrack(myLocalStream.getTracks().find(t => t.kind == sender.track.kind), myLocalStream)
});
It looks like after replacing the tracks, the browser has still some references to running tracks, that I don't know how to stop. Any suggestions?
来源:https://stackoverflow.com/questions/61684067/webrtc-stop-local-tracks-not-disabling-webcam-after-using-replacetrack