Make old video streams stop

This commit is contained in:
Fabian Stamm 2021-12-05 17:46:52 +01:00
parent e887908a45
commit 3f8358fa4c

View File

@ -96,6 +96,8 @@ function bitrateTransform(sdp) {
return res;
}
let currentStream = undefined;
peer.on("open", (id) => {
console.log("ID", id);
sf.streamId_text = id;
@ -115,6 +117,10 @@ peer.on("open", (id) => {
video: true,
})
.then((stream) => {
if(currentStream) {
currentStream.getTracks().forEach(track => track.stop())
}
currentStream = stream;
let v = sf.localVideo;
v.srcObject = stream;
v.play();