Web/API/MediaSession/metadata

From Get docs

This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.


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.

Syntax

var mediaMetadata = navigator.mediaSession.metadata;
navigator.mediaSession.metadata = mediaMetadata;

Value

An instance of MediaMetadata containing information about the media currently being played.

Example

The following example checks for compatibility and creates a new media session with the relevant metadata:

if ('mediaSession' in navigator) {
  navigator.mediaSession.metadata = new MediaMetadata({
    title: 'Unforgettable',
    artist: 'Nat King Cole',
    album: 'The Ultimate Collection (Remastered)',
    artwork: [
      { src: 'https://dummyimage.com/96x96',   sizes: '96x96',   type: 'image/png' },
      { src: 'https://dummyimage.com/128x128', sizes: '128x128', type: 'image/png' },
      { src: 'https://dummyimage.com/192x192', sizes: '192x192', type: 'image/png' },
      { src: 'https://dummyimage.com/256x256', sizes: '256x256', type: 'image/png' },
      { src: 'https://dummyimage.com/384x384', sizes: '384x384', type: 'image/png' },
      { src: 'https://dummyimage.com/512x512', sizes: '512x512', type: 'image/png' },
    ]
  });

}

Specifications

Specification Status Comment
Media Session StandardThe definition of 'MediaSession.metadata' in that specification. Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

metadata

Experimental'

Chrome

Full support 73

Edge

Full support ≤79

Firefox Full support 71

Disabled'

Full support 71

Disabled'

Disabled' From version 71: this feature is behind the dom.media.mediasession.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE

No support No

Opera

Full support Yes

Safari

No support No

WebView Android

No support No

Chrome Android

Full support 57

Firefox Android

No support No

Opera Android

No support No

Safari iOS

No support No

Samsung Internet Android

Full support 7.0

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.'
User must explicitly enable this feature.