To let users know what's currently playing in their browser and control it without returning to the page that launched it, the Media Session API has b

The Media Session API lets you customize media notifications and controls.

submited by
Style Pass
2021-05-17 06:17:04

To let users know what's currently playing in their browser and control it without returning to the page that launched it, the Media Session API has been introduced. It allows web developers to customize this experience through metadata in custom media notifications, media events such as playing, pausing, seeking, track changing, and video conferencing events such as mute/unmute microphone, turnon/turnoff camera, and hang up. These customizations are available in several contexts including desktop media hubs, media notifications on mobile, and even on wearable devices. I'll describe these customizations in this article.

At the time of writing, Chrome is the only browser that supports the Media Session API both on desktop and mobile. Firefox has partial support for the Media Session API on desktop behind a flag, and Samsung Internet also has partial support. See Browser compatibility for up-to-date information.

Example 1: If users press the "next track" media key of their keyboard, web developers can handle this user action whether Chrome is in the foreground or the background.

Leave a Comment