o2buvioma: Autoplay mobile feed videos muted when they snap into view, with a session mute toggle and tap to pause

This commit is contained in:
2026-10-20 10:22:39 -06:00
parent 6af225afa5
commit e37ec780a9
5 changed files with 254 additions and 22 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* Mobile feed autoplay: the session's mute choice and how a failed play() is read.
* The choice lives in memory only, for this page session: videos start muted
* (browsers only autoplay muted video) until the person unmutes one.
*/
let sessionMuted = true;
/** True until the person unmutes a video in this session. */
export function getSessionMuted(): boolean {
return sessionMuted;
}
/** Remember the person's mute choice for the videos that play after this one. */
export function setSessionMuted(muted: boolean): void {
sessionMuted = muted;
}
/**
* True when play() was refused by the browser's autoplay policy. A play() that
* was cut short by pause() (AbortError) is not a refusal.
*/
export function isAutoplayBlocked(error: unknown): boolean {
return !!error && typeof error === "object" && (error as { name?: unknown }).name === "NotAllowedError";
}