0

How can I set the name (label) of HTML5 <video> element that browsers (like Chrome) and Windows OS display?

Like the title that Windows shows for this youtube video (when changing speaker volume):

enter image description here

Currently for me the page title is shown (the title set in page head).
I tried adding a title="..." attribute to the video element but it had no effect. Also didn't find a solution on StackOverflow.

Mahozad
  • 18,032
  • 13
  • 118
  • 133

2 Answers2

0

I'm not sure for the video. But in some browsers, mediaSession worked for me. Javascript...

    if ('mediaSession' in navigator) {
      navigator.mediaSession.metadata = new MediaMetadata({
      title: 'name',
      artist: '',
      album: '',
      artwork: [{ src: '...' }]
      });
  }
Hiru Hira
  • 21
  • 5
0

As the other answer stated, it can be done with JavaScript and Media Session API.
Check out this YouTube video.

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/128x128", sizes: "128x128", type: "image/png" },
      { src: "https://dummyimage.com/512x512", sizes: "512x512", type: "image/png" }
    ]
  });
}
Mahozad
  • 18,032
  • 13
  • 118
  • 133