Merge pull request #2057 from PR0M3TH3AN/ai/fix-webtorrent-playback-stall-8715021047913895590

Fix WebTorrent playback stall (gray screen)
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-01 15:31:30 -05:00
commit 38209dc6e7
1 file changed
+20 -14
+20 -14
View File
@@ -747,16 +747,19 @@ export class TorrentClient {
this.log("Video error:", e.target.error);
});
videoElement.addEventListener(
"canplay",
() => {
this.attemptAutoplay(videoElement, "chrome");
},
{ once: true }
);
const tryStart = () => {
this.attemptAutoplay(videoElement, "chrome");
};
videoElement.addEventListener("canplay", tryStart, { once: true });
videoElement.addEventListener("loadeddata", tryStart, { once: true });
try {
file.streamTo(videoElement);
// If the video is already ready (e.g. from cache or fast load), try starting immediately
if (videoElement.readyState >= 3) {
tryStart();
}
this.currentTorrent = torrent;
resolve(torrent);
} catch (err) {
@@ -786,16 +789,19 @@ export class TorrentClient {
this.log("Video error (Firefox path):", e.target.error);
});
videoElement.addEventListener(
"canplay",
() => {
this.attemptAutoplay(videoElement, "firefox");
},
{ once: true }
);
const tryStart = () => {
this.attemptAutoplay(videoElement, "firefox");
};
videoElement.addEventListener("canplay", tryStart, { once: true });
videoElement.addEventListener("loadeddata", tryStart, { once: true });
try {
file.streamTo(videoElement, { highWaterMark: 256 * 1024 });
// If the video is already ready (e.g. from cache or fast load), try starting immediately
if (videoElement.readyState >= 3) {
tryStart();
}
this.currentTorrent = torrent;
resolve(torrent);
} catch (err) {