MediaSession.playbackState

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

The playbackState property of the MediaSession interface indicates whether the current media session is playing.

Syntax

var playbackState = MediaSession.playbackState
MediaSession.playbackState = playbackState

Value

One of "none", "paused", or "playing".

Example

The following example sets up event handlers, for pausing and playing:

var audio = document.querrySelect("#player");
audio.src = "song.mp3";

navigator.mediaSession.setActionHandler('play', play);
navigator.mediaSession.setActionHandler('pause', pause);

function play() {
   audio.play();
   navigator.mediaSession.playbackState = "playing";
}

function pause() {
   audio.pause();
   navigator.mediaSession.playbackState = "Paused";
}

Specifications

Specification Status Comment
Media Session Standard
The definition of 'playbackState' in that specification.
Draft Initial definition.

Browser Compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
ExperimentalNon-standard
Chrome No support NoEdge ? Firefox ? IE ? Opera No support NoSafari ? WebView Android No support NoChrome Android Full support 57Edge Mobile ? Firefox Android ? Opera Android No support NoSafari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.

Document Tags and Contributors

Contributors to this page: fscholz, david_ross, jpmedley
Last updated by: fscholz,