Class MediaSession
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The MediaSession interface of the {{domxref("Media Session API", "", "", "nocode")}} allows a web page to provide custom behaviors for standard media playback interactions, and to report metadata that can be sent by the user agent to the device or operating system for presentation in standardized user interface elements.
[Value("MediaSession")]
public class MediaSession
- Inheritance
-
MediaSession
- Inherited Members
Remarks
For example, a smartphone might have a standard panel in its lock screen that provides controls for media playback and information display. A browser on the device can use MediaSession to make browser playback controllable from that standard/global user interface.
Constructors
MediaSession()
public MediaSession()
Properties
Metadata
The metadata property of the MediaSession
interface contains a MediaMetadata object providing descriptive
information about the currently playing media, or null if the metadata has
not been set. This metadata is provided by the browser to the device for presentation in
any standard media control user interface the device might offer.
[Value("metadata")]
public MediaMetadata? Metadata { get; set; }
Property Value
- MediaMetadata
An instance of MediaMetadata containing information about the media
currently being played.
Remarks
PlaybackState
The playbackState property of the
MediaSession interface indicates whether the current media session is
playing or paused.
[Value("playbackState")]
public MediaSessionPlaybackState PlaybackState { get; set; }
Property Value
- MediaSessionPlaybackState
A string indicating the current playback state of the media session.
The value may be one of the following:
Remarks
Methods
SetActionHandler(MediaSessionAction, MediaSessionActionHandler?)
The setActionHandler() method of the MediaSession interface sets a handler for a media session action.
These actions let a web app receive notifications when the user engages a device's built-in physical or onscreen media controls, such as play, stop, or seek buttons.
[Value("setActionHandler")]
public GlobalObject.Undefined SetActionHandler(MediaSessionAction action, MediaSessionActionHandler? handler)
Parameters
actionMediaSessionActionhandlerMediaSessionActionHandler
Returns
Remarks
SetCameraActive(bool)
The setCameraActive() method of the MediaSession interface is used to indicate to the user agent whether the user's camera is considered to be active.
[Value("setCameraActive")]
public Task<GlobalObject.Undefined> SetCameraActive(bool active)
Parameters
activebool
Returns
- Task<GlobalObject.Undefined>
None (GlobalObject.Undefined).
Remarks
Call this method on the navigator object's
MediaSession object.
Note that the status of the camera is not tracked in the MediaSession itself, but must be tracked separately.
SetMicrophoneActive(bool)
The setMicrophoneActive() method of the MediaSession interface is used to indicate to the user agent whether the user's microphone is considered to be currently muted.
[Value("setMicrophoneActive")]
public Task<GlobalObject.Undefined> SetMicrophoneActive(bool active)
Parameters
activebool
Returns
- Task<GlobalObject.Undefined>
None (GlobalObject.Undefined).
Remarks
Call this method on the navigator object's
MediaSession object.
Note that the status of the microphone is not tracked in the MediaSession itself, but must be tracked separately.
SetPositionState(MediaPositionState)
The setPositionState() method of the
MediaSession interface is used to update the current
document's media playback position and speed for presentation by user's device in any
kind of interface that provides details about ongoing media. This can be
particularly useful if your code implements a player for type of media not directly
supported by the browser.
[Value("setPositionState")]
public GlobalObject.Undefined SetPositionState(MediaPositionState state = null)
Parameters
stateMediaPositionState
Returns
Remarks
Call this method on the navigator object's
MediaSession object.
SetScreenshareActive(bool)
NOTE
ExperimentalsetScreenshareActive() method of the MediaSession interface is used to indicate to the user agent whether the user's screenshare is considered to be active.
[Value("setScreenshareActive")]
public Task<GlobalObject.Undefined> SetScreenshareActive(bool active)
Parameters
activebool
Returns
- Task<GlobalObject.Undefined>
None (GlobalObject.Undefined).
Remarks
Call this method on the navigator object's MediaSession object.
Note that the status of the screenshare is not tracked in the MediaSession itself, but must be tracked separately.