WebRTC stop local tracks not disabling webcam after using replaceTrack

梦想与她 提交于 2020-12-16 04:37:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!