The read-only Navigator
property mediaSession
returns a MediaSession
object that can be used to share with the browser metadata and other information about the current playback state of media being handled by a document.
This information may, in turn, be shared with the device and/or operating system in order to a device's standard media control user experience to describe and control the playback of the media.
In addition, the MediaSession
interface provides the setActionHandler()
method, which lets you receive events when the user engages device controls such as either onscreen or physical play, pause, seek, and other similar controls. An internet radio app, for example, can use setActionHandler()
to let the media controls on a keyboard or elsewhere on the user's device be used to control the app's media playback.