/** * 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"; }