1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Handle removetrack event on streamed videos.

Probably useless, but I'm supersticious.
This commit is contained in:
Juliusz Chroboczek 2020-11-24 23:22:24 +01:00
parent 6a9ab96902
commit 6e548deded

View file

@ -902,13 +902,25 @@ async function addFileMedia(file) {
stream.onaddtrack = function(e) {
let t = e.track;
c.pc.addTrack(t, stream);
t.onended = e => {
delUpMedia(c);
}
c.labels[t.id] = t.kind;
c.onstats = gotUpStats;
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);
video.play();
setButtonsVisibility()