coderef

Media sessionLimited availability

The navigator.mediaSession API integrates with platform UI for media playback. It can be used to set metadata such as title and artwork, and to handle user actions like playing, pausing, or seeking.

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
1–72Not supported
73+Supportedsince Mar 12, 2019
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–81Not supported
82+Supportedsince Oct 20, 2020
Current: 157
Safari
1–14.1Not supported
15+Supportedsince Sep 20, 2021
Current: 27
MobileChrome Android
18–56Not supported
57+Supportedsince Mar 16, 2017
Current: 155
Firefox Android
✕Not supportedup to 157
Current: 157
Safari iOS
1–14.5Not supported
15+Supportedsince Sep 20, 2021
Current: 27

How to use

Not supported in Firefox Android. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN: ChapterInformation.

Feature detection

JS · check before using
if ("MediaSession" in globalThis) {
  // MediaSession is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (34). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
ChapterInformation127127✕✕127✕✕
ChapterInformation.artwork127127✕✕127✕✕
ChapterInformation.startTime127127✕✕127✕✕
ChapterInformation.title127127✕✕127✕✕
MediaMetadata5779821457✕14
MediaMetadata.MediaMetadata5779821457✕14
MediaMetadata.album5779821457✕14
MediaMetadata.artist5779821457✕14
MediaMetadata.artwork5779821457✕14
MediaMetadata.chapterInfo127127✕✕127✕✕
MediaMetadata.title5779821457✕14
MediaSession7379821557✕15
MediaSession.metadata7379821557✕15
MediaSession.playbackState7379821557✕15
MediaSession.setActionHandler7379821557✕15
MediaSession.setActionHandler.hangup_type9393✕✕93✕✕
MediaSession.setActionHandler.nextslide_type111111✕✕111✕✕
MediaSession.setActionHandler.nexttrack_type7379821557✕15
MediaSession.setActionHandler.pause_type7379821557✕15
MediaSession.setActionHandler.play_type7379821557✕15
Show 14 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
MediaSession.setActionHandler.previousslide_type111111✕✕111✕✕
MediaSession.setActionHandler.previoustrack_type7379821557✕15
MediaSession.setActionHandler.seekbackward_type7379821557✕15
MediaSession.setActionHandler.seekforward_type7379821557✕15
MediaSession.setActionHandler.seekto_type7879821578✕15
MediaSession.setActionHandler.skipad_type1281288215128✕15
MediaSession.setActionHandler.stop_type7779821577✕15
MediaSession.setActionHandler.togglecamera_type9393✕18.493✕18.4
MediaSession.setActionHandler.togglemicrophone_type9393✕18.493✕18.4
MediaSession.setCameraActive9393✕18.493✕18.4
MediaSession.setMicrophoneActive9393✕18.493✕18.4
MediaSession.setPositionState8181821557✕15
MediaSession.setScreenshareActive✕✕✕18.4✕✕18.4
Navigator.mediaSession73798215578215