mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Handle removetrack event on streamed videos.
Probably useless, but I'm supersticious.
This commit is contained in:
parent
6a9ab96902
commit
6e548deded
1 changed files with 15 additions and 3 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue