Commit 6e548ded authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Handle removetrack event on streamed videos.

Probably useless, but I'm supersticious.
parent 6a9ab969
...@@ -902,13 +902,25 @@ async function addFileMedia(file) { ...@@ -902,13 +902,25 @@ async function addFileMedia(file) {
stream.onaddtrack = function(e) { stream.onaddtrack = function(e) {
let t = e.track; let t = e.track;
c.pc.addTrack(t, stream); c.pc.addTrack(t, stream);
t.onended = e => {
delUpMedia(c);
}
c.labels[t.id] = t.kind; c.labels[t.id] = t.kind;
c.onstats = gotUpStats; c.onstats = gotUpStats;
c.setStatsInterval(2000); c.setStatsInterval(2000);
}; };
stream.onremovetrack = function(e) {
let t = e.track;
delete(c.labels[t.id]);
/** @type {RTCRtpSender} */
let sender;
c.pc.getSenders().forEach(s => {
if(s.track === t)
sender = s;
});
if(sender) {
c.pc.removeTrack(sender)
} else
console.warn('Removing unknown track');
};
setMedia(c, true, video); setMedia(c, true, video);
video.play(); video.play();
setButtonsVisibility() setButtonsVisibility()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment