Files
v10/dist/dev/core/state.d.ts
T

353 lines
11 KiB
TypeScript

import { ErrorLike, MediaFeatureAvailability, MediaStreamType, TextTrackKind } from "./types.js";
//#region src/core/state.d.ts
interface MediaPlaybackState {
/**
* Whether playback is paused.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/paused
*/
paused: boolean;
/**
* Whether playback has reached the end.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended
*/
ended: boolean;
/**
* Whether playback has started (played or seeked).
*/
started: boolean;
/**
* Whether playback is stalled waiting for data.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/waiting_event
*/
waiting: boolean;
/**
* Start playback.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
*/
play(): Promise<void>;
/**
* Pause playback.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause
*/
pause(): void;
/** Toggle play/pause. Returns `true` if playback started. */
togglePaused(): boolean;
}
interface MediaVolumeState {
/**
* Volume level from 0 (silent) to 1 (max).
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume
*/
volume: number;
/**
* Whether audio is muted.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/muted
*/
muted: boolean;
/**
* Whether volume can be programmatically set on this platform.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume
*/
volumeAvailability: MediaFeatureAvailability;
/**
* Set volume (clamped 0-1). Returns the clamped value.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume
*/
setVolume(volume: number): number;
/**
* Toggle mute state. Returns the new muted value.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/muted
*/
toggleMuted(): boolean;
}
interface MediaTimeState {
/**
* Current playback position in seconds.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime
*/
currentTime: number;
/**
* Total duration in seconds (0 if unknown).
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/duration
*/
duration: number;
/**
* Whether a seek operation is in progress.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeking
*/
seeking: boolean;
/**
* Seek to a time in seconds. Returns the actual position after seek.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime
*/
seek(time: number): Promise<number>;
}
interface MediaSourceState {
/**
* Current media source URL (null if none).
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentSrc
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/src
*/
source: string | null;
/**
* Whether enough data is loaded to begin playback.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState
*/
canPlay: boolean;
/**
* Load a new media source. Returns the new source URL.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/src
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/load
*/
loadSource(src: string): string;
}
interface MediaStreamTypeState {
/**
* Current stream delivery type.
*
* Components use this to toggle live-specific UI (e.g. a live indicator,
* a "jump to live edge" affordance, or hiding the time display).
*
* @see {@link MediaStreamTypes} for the canonical string values.
* @see https://github.com/video-dev/media-ui-extensions/blob/main/proposals/0010-stream-type.md
*/
streamType: MediaStreamType;
}
interface MediaLiveState {
/**
* Presentation time marking the start of the Live Edge Window.
*
* Playing at the live edge when `currentTime >= liveEdgeStart`. `NaN`
* when the stream isn't live or the value is unknown.
*
* @see https://github.com/video-dev/media-ui-extensions/blob/main/proposals/0007-live-edge.md
*/
liveEdgeStart: number;
/**
* Offset representing the seekable range size for live content.
*
* `0` for standard latency live, `Infinity` for DVR, `NaN` for on-demand
* or unknown.
*/
targetLiveWindow: number;
}
interface MediaBufferState {
/**
* Buffered time ranges as [start, end] tuples.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered
*/
buffered: [number, number][];
/**
* Seekable time ranges as [start, end] tuples.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable
*/
seekable: [number, number][];
}
interface MediaFullscreenState {
/**
* Whether fullscreen mode is currently active.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
*/
fullscreen: boolean;
/**
* Whether fullscreen can be requested on this platform.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenEnabled
*/
fullscreenAvailability: MediaFeatureAvailability;
/**
* Enter fullscreen mode. Tries container first, falls back to media element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
*/
requestFullscreen(): Promise<void>;
/**
* Exit fullscreen mode.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen
*/
exitFullscreen(): Promise<void>;
/** Toggle fullscreen mode. */
toggleFullscreen(): Promise<void>;
}
interface MediaControlsState {
/** Whether the user has recently interacted with the player. */
userActive: boolean;
/** Whether controls should be visible (userActive || paused). */
controlsVisible: boolean;
/** Toggle controls visibility. Returns the new `controlsVisible` value. */
toggleControls(): boolean;
}
interface MediaPlaybackRateState {
/**
* Available playback rates.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate
*/
readonly playbackRates: readonly number[];
/**
* Current playback rate.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate
*/
playbackRate: number;
/**
* Set the playback rate.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate
*/
setPlaybackRate(rate: number): void;
}
interface MediaVideoRendition {
id?: string;
width?: number;
height?: number;
bitrate?: number;
frameRate?: number;
codec?: string;
selected: boolean;
}
interface MediaQualityState {
/** Video renditions available for manual quality selection. */
videoRenditionList: MediaVideoRendition[];
/** Video rendition currently playing, including when automatic ABR is selected. */
activeVideoRendition: MediaVideoRendition | null;
/** Select a video rendition by menu value, or automatic ABR with `"auto"`. */
selectVideoRendition(value: string): void;
}
interface MediaAudioTrack {
id?: string;
kind?: string;
label: string;
language: string;
enabled: boolean;
}
interface MediaAudioTrackState {
/** Audio tracks available for manual track selection. */
audioTrackList: MediaAudioTrack[];
/** Select an audio track by menu value. */
selectAudioTrack(value: string): void;
}
/**
* A text cue.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/VTTCue
*/
interface MediaTextCue {
startTime: number;
endTime: number;
text: string;
}
/**
* The mode of a text track.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/mode
*/
type TextTrackMode = 'showing' | 'disabled' | 'hidden';
/**
* A text track.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack
*/
interface MediaTextTrack<Kind extends string = TextTrackKind> {
id?: string;
kind: Kind;
label: string;
language: string;
mode: TextTrackMode;
}
interface MediaTextTrackState {
/** Cues from the first `kind="chapters"` track. */
chaptersCues: MediaTextCue[];
/** Cues from the first `kind="metadata" label="thumbnails"` track. */
thumbnailCues: MediaTextCue[];
/** The `<track>` element's `src` for resolving relative cue text URLs. */
thumbnailTrackSrc: string | null;
/** All text tracks available on the media element. */
textTrackList: MediaTextTrack[];
/** Whether captions/subtitles are currently enabled. */
subtitlesShowing: boolean;
/** Toggle captions/subtitles visibility. Returns the new enabled value. */
toggleSubtitles(forceShow?: boolean): boolean;
/** Select a captions/subtitles track by menu value, or disable with `"off"`. */
selectSubtitlesTrack(value: string): void;
}
interface MediaErrorState {
/**
* The current media error, or null if none.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error
*/
error: ErrorLike | null;
/** Dismiss the current error by clearing it. */
dismissError(): void;
}
type RemotePlaybackConnectionState = 'disconnected' | 'connecting' | 'connected';
interface MediaRemotePlaybackState {
/**
* Current remote playback connection state.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/RemotePlayback/state
*/
remotePlaybackState: RemotePlaybackConnectionState;
/**
* Whether remote playback can be requested on this platform.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/RemotePlayback
*/
remotePlaybackAvailability: MediaFeatureAvailability;
/** Toggle the remote playback connection. */
toggleRemotePlayback(): Promise<void>;
}
interface MediaPictureInPictureState {
/**
* Whether picture-in-picture mode is currently active.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API
*/
pip: boolean;
/**
* Whether picture-in-picture can be requested on this platform.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/pictureInPictureEnabled
*/
pipAvailability: MediaFeatureAvailability;
/**
* Enter picture-in-picture mode.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/requestPictureInPicture
*/
requestPictureInPicture(): Promise<void>;
/**
* Exit picture-in-picture mode.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/exitPictureInPicture
*/
exitPictureInPicture(): Promise<void>;
/** Toggle picture-in-picture mode. */
togglePictureInPicture(): Promise<void>;
}
//#endregion
export { MediaAudioTrack, MediaAudioTrackState, MediaBufferState, MediaControlsState, MediaErrorState, MediaFullscreenState, MediaLiveState, MediaPictureInPictureState, MediaPlaybackRateState, MediaPlaybackState, MediaQualityState, MediaRemotePlaybackState, MediaSourceState, MediaStreamTypeState, MediaTextCue, MediaTextTrack, MediaTextTrackState, MediaTimeState, MediaVideoRendition, MediaVolumeState, RemotePlaybackConnectionState, TextTrackMode };
//# sourceMappingURL=state.d.ts.map