--- url: "https://web.dev/articles/media/media-session/pattern" titulek: "web.dev" h1: "" popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/media/media-session/pattern" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:28:40" znaku: 2543 slov: 281 kodovani: "iso-8859-2" sha256: "210df6825b0f5085dbbe8e7183e6762423de2b017eedb197970b9319356c183a" --- Stay organized with collections Save and categorize content based on your preferences. HTML ` How to customize media notifications

How to customize media notifications

Credits: Media files are Š copyright Blender Foundation | www.blender.org.

` CSS `:root { color-scheme: dark light; } html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body { margin: 1rem; font-family: system-ui, sans-serif; } video { display: block; margin-top: 10px; max-width: 100%; }` JS `const video = document.querySelector("video"); navigator.mediaSession.metadata = new MediaMetadata({ title: "Caminandes 2: Gran Dillama - Blender Animated Short", artist: "Blender Foundation", artwork: [ { src: "https://storage.googleapis.com/media-session/caminandes/artwork-96.png", sizes: "96x96" }, { src: "https://storage.googleapis.com/media-session/caminandes/artwork-128.png", sizes: "128x128" }, { src: "https://storage.googleapis.com/media-session/caminandes/artwork-256.png", sizes: "256x256" }, { src: "https://storage.googleapis.com/media-session/caminandes/artwork-512.png", sizes: "512x512" }, ], }); navigator.mediaSession.setActionHandler("play", async () => { // Resume playback try { await video.play(); } catch (err) { console.error(err.name, err.message); } }); navigator.mediaSession.setActionHandler("pause", () => { // Pause active playback video.pause(); }); video.addEventListener("play", () => { navigator.mediaSession.playbackState = "playing"; }); video.addEventListener("pause", () => { navigator.mediaSession.playbackState = "paused"; });` Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-07-29 UTC.