feat: add error handling to player core functions

This commit is contained in:
2026-06-16 14:00:38 +02:00
committed by Milas Holsting
parent 3a1a2129d9
commit 2a8294c405
9 changed files with 45 additions and 22 deletions

View File

@@ -172,7 +172,8 @@ const initPlayer = (): void => {
sessionStorage.removeItem("mal:resume-after-mode-switch");
const parsed = Number(raw);
return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
} catch {
} catch (error) {
console.error("failed to parse resume state:", error);
return null;
}
})();
@@ -200,7 +201,9 @@ const initPlayer = (): void => {
// autoplay if not already playing (inline script may have already called play())
// but don't autoplay if we've reached the end
if (!isAtEnd && (state.playback.shouldAutoPlay || state.elements.video.paused)) {
state.elements.video.play().catch(() => undefined);
state.elements.video.play().catch((error) => {
console.debug("failed to autoplay video:", error);
});
}
updateTimeline(state.elements.video.currentTime);
@@ -279,7 +282,8 @@ const initPlayer = (): void => {
try {
(e.currentTarget as HTMLElement).setPointerCapture((e as PointerEvent).pointerId);
} catch (e) {
console.warn("Failed to capture pointer:", e);
console.error("failed to capture pointer:", e);
throw e;
}
scrubToPointer(e.clientX, true);
},