I'm trying to customize the display in Chrome's Global Media Controls. So I used navigator.mediaSession.metadata
to set the title and other things and it works.
But I also want to set the background image, like in the example below:
I tried using the following code:
navigator.mediaSession.metadata.artwork = [{sizes, src, type}];
But src
is a blob URL, like this: blob:http://localhost:3000/8afe91b0-4689-4f6b-9984-21aedc834253
I know this blob URL is OK since I can use it in as an <img>
source and it's correctly displayed.
I also tried to fetch the blob itself and using URL.createObjectURL()
but this gives me another (valid) blob URL and it doesn't work any better.
Final note: I think the way I set the artwork
property is correct because if I use a "regular" image URL, it works.
EDIT 1: I've just discovered that while it's not working in the control view activated via the button, the image appears correctly when I use my keyboard media keys:
EDIT 2:
Another discovery: it works (i.e. using a blob URL as src
) with JPG images but not with PNG images.
I ended up using JPG images which work just fine.
So, my conclusion is: you can use a blob URL as an artwork source, as follows:
My other conclusion is that there's a bug with PNG images (see EDIT 1 in my question).