How to set the HTML video title that is shown in Chrome and Windows?

0

Issue

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.

Solution

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" }
    ]
  });
}

Answered By – Mahozad

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More