Skip to main content

Type Alias: SleepTimerState

type SleepTimerState =
| {
mode: "duration";
remainingSeconds: number;
}
| {
mode: "trackEnd";
remainingSeconds?: number;
};

Defined in: packages/media-session/src/types.ts:185

What the native sleep timer is doing, as MediaServiceApi.getSleepTimer reports it.

A discriminated union rather than { mode, remainingSeconds? } so the one case that has no number — a trackEnd timer whose deadline is not computable yet — cannot be confused with "not armed" by an optional-chaining accident.

Union Members

Type Literal

{
mode: "duration";
remainingSeconds: number;
}

MediaServiceApi.setSleepTimer: a countdown, always with a number.


Type Literal

{
mode: "trackEnd";
remainingSeconds?: number;
}

MediaServiceApi.setSleepTimerToTrackEnd.

remainingSeconds is present while the current item has a duration and playback is advancing, and absent otherwise — a live stream, a paused player, or a track whose duration the app has not broadcast yet. Absent means "armed, deadline unknown", never "not armed".