MediaSessionController
Controls an active media session.
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
isSupported | readonly | boolean | Whether the media session API is available in the current environment. Every other method is a no-op when it is false. |
setMetadata | public | (metadata?) => void | Update, or clear when omitted, the presented metadata. |
setPlaybackState | public | (playbackState) => void | Update the presented playback state. |
setMicrophoneActive | public | (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. |
setCameraActive | public | (active) => Promise<void> | Update whether the platform should present the camera as active, with the same caveat as MediaSessionController.setMicrophoneActive. |
setScreenshareActive | public | (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. |
setPositionState | public | (state?) => void | Update, 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. |
destroy | public | () => void | Unregister 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
| Parameter | Type |
|---|---|
handlers | Partial<Record<ExtendedMediaSessionAction, MediaSessionActionHandler>> |
Returns
void
deregisterActions()
deregisterActions(actions): void;
Parameters
| Parameter | Type |
|---|---|
actions | ExtendedMediaSessionAction[] |
Returns
void