Skip to main content

MediaSessionController

Controls an active media session.

Properties​

PropertyModifierTypeDescription
isSupportedreadonlybooleanWhether the media session API is available in the current environment. Every other method is a no-op when it is false.
setMetadatapublic(metadata?) => voidUpdate, or clear when omitted, the presented metadata.
setPlaybackStatepublic(playbackState) => voidUpdate the presented playback state.
setMicrophoneActivepublic(active) => Promise<void>Update whether the platform should present the microphone as active. A no-op on platforms that implement this as a command mutating the real tracks, unless applyImperativeCaptureState was set.
setCameraActivepublic(active) => Promise<void>Update whether the platform should present the camera as active, with the same caveat as MediaSessionController.setMicrophoneActive.
setScreenshareActivepublic(active) => Promise<void>Update whether the platform should present the screen as shared, with the same caveat as MediaSessionController.setMicrophoneActive. Only implemented by WebKit so far.
setPositionStatepublic(state?) => voidUpdate, or reset when omitted, the presented playback position. Pass duration: Infinity for a live stream such as a call, which makes the platform present an elapsed clock rather than a seekable scrub bar. States the user agent rejects are logged and otherwise ignored.
destroypublic() => voidUnregister every handler registered by this session and reset the metadata, the playback state and the position state. Terminal and idempotent: every other method becomes a no-op afterwards, so a slower owner cannot resurrect the platform's media controls.

Methods​

registerActions()​

registerActions(handlers): void;

Parameters​

ParameterType
handlersPartial<Record<ExtendedMediaSessionAction, MediaSessionActionHandler>>

Returns​

void


deregisterActions()​

deregisterActions(actions): void;

Parameters​

ParameterType
actionsExtendedMediaSessionAction[]

Returns​

void