Skip to main content

MediaSessionLike

The subset of the navigator.mediaSession API used by createMediaSession, so that an equivalent implementation can be injected, e.g. in tests.

Properties​

PropertyTypeDescription
metadataMediaMetadata | nullDescriptive information about the currently played media.
playbackStateMediaSessionPlaybackStateWhether the media session is currently playing or paused.

Methods​

setActionHandler()​

setActionHandler(action, handler): void;

Register, or unregister when the handler is null, a handler for the given media session action.

Parameters​

ParameterType
actionExtendedMediaSessionAction
handlerMediaSessionActionHandler | null

Returns​

void


setCameraActive()?​

optional setCameraActive(active): Promise<void>;

Tell the user agent whether the camera is considered to be active.

P.S. Safari's impl. is an imperative action to change the track's muted stated whereas Chromium-based browsers indicate to the user agent the microphone capture state desired by the page

Parameters​

ParameterType
activeboolean

Returns​

Promise<void>


setMicrophoneActive()?​

optional setMicrophoneActive(active): Promise<void>;

Tell the user agent whether the microphone is considered to be active.

P.S. Safari's impl. is an imperative action to change the track's muted stated whereas Chromium-based browsers indicate to the user agent the microphone capture state desired by the page

Parameters​

ParameterType
activeboolean

Returns​

Promise<void>


setScreenshareActive()?​

optional setScreenshareActive(active): Promise<void>;

Tell the user agent whether the screen is considered to be shared. Only specified so far, no browser implements it yet.

Parameters​

ParameterType
activeboolean

Returns​

Promise<void>


setPositionState()?​

optional setPositionState(state?): void;

Present the playback position, or reset it when called without a state. Throws a TypeError for a state the user agent considers invalid.

Parameters​

ParameterType
state?MediaPositionState

Returns​

void