mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-31 18:02:27 +00:00
Clear srcObject before replaying torrents
This commit is contained in:
1 parent
e7d895f123
commit
8e42816ec5
1 file changed
+13
@@ -1247,12 +1247,20 @@ class bitvidApp {
|
||||
if (this.videoElement) {
|
||||
this.videoElement.pause();
|
||||
this.videoElement.src = "";
|
||||
// When WebTorrent (or other MediaSource based flows) mount a stream they
|
||||
// set `srcObject` behind the scenes. Forgetting to clear it leaves the
|
||||
// detached MediaSource hanging around which breaks the next playback
|
||||
// attempt. Always null it out alongside the normal `src` reset.
|
||||
this.videoElement.srcObject = null;
|
||||
this.videoElement.load();
|
||||
}
|
||||
// If there's a modal video
|
||||
if (this.modalVideo) {
|
||||
this.modalVideo.pause();
|
||||
this.modalVideo.src = "";
|
||||
// See comment above—keep the `srcObject` reset paired with the `src`
|
||||
// wipe so magnet-only replays do not regress into the grey screen bug.
|
||||
this.modalVideo.srcObject = null;
|
||||
this.modalVideo.load();
|
||||
}
|
||||
// Tell webtorrent to cleanup
|
||||
@@ -2372,8 +2380,13 @@ class bitvidApp {
|
||||
await torrentClient.cleanup();
|
||||
|
||||
this.modalVideo.pause();
|
||||
// Clearing the WebTorrent attachment requires wiping both `src` and
|
||||
// `srcObject`. Multiple regressions have shipped where we only blanked
|
||||
// `src`, leaving the old MediaSource wired up and the next magnet would
|
||||
// stall on a grey frame. Always clear both before calling `load()`.
|
||||
this.modalVideo.src = "";
|
||||
this.modalVideo.removeAttribute("src");
|
||||
this.modalVideo.srcObject = null;
|
||||
this.modalVideo.load();
|
||||
|
||||
this.resetTorrentStats();
|
||||
|
||||
Reference in new issue
Block a user