-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When and how should we load media metadata artwork? #58
Comments
Right now the spec does not say we must wait for the fetch steps to complete before showing media controls. I agree it could be good to have a preloaded image. Perhaps we should define 'display media controls' steps similar to notification's display steps that wait until any related fetch steps have completed. Alternatively, maybe it is ok to 'lazy load' artwork URLs so the fetch steps do not block any display steps. WDYT? |
I can imagine being okay with showing the artwork at a later point (if you're bandwidth constrained, or the user skips very quickly, or some such), but I think by default you want to show the correct artwork and the API needs to accommodate for that. An alternative could be that you pass a And the examples should indicate that while you play the current song, you're already caching bits for the next song. And that once you start playing the next song, enough is cached to show the image and play it. (And then you start caching for the song after that of course, or some such.) |
setMetadata itself could return a promise that resolves when the artwork is loaded. Not sure if we'll regret that if we end up with more than one kind of artwork, though. |
It seems |
Perhaps as with |
Is |
Passing a URL might still be okay, but in that case you need a distinct object I think that holds all the metadata and is responsible for loading assets. And then separately you can decide when that object is going to take over from what is displayed now. [Constructor(MediaSessionDataInit init)]
interface MediaSessionData {
...
readonly attribute Promise<boolean> done;
};
dictionary MediaSessionDataInit {
...
};
partial interface MediaSession {
void setSessionData(MediaSessionData data);
}; |
Yeah, something like that could work. We had talked about having a mutable |
This issue was originally discussed in #44. One way a web developer could ensure media artwork loads immediately is to pass a pre-fetched Media artwork URL fetching is (currently) unobservable from a web page so perhaps we could defer to the implementation stage to figure out exactly when this fetch should happen. It feels like we can have interoperability in the JS platform without initially specifying this and there are different fetch strategies that could work quite well here. I could be wrong :/ |
We should not rely on fetching blob or data URLs (especially the former) to happen synchronously. |
Right. I also plan to remove invocation of the fetch steps from the At this point it's unclear if we need to change the API. If we want to discuss changing |
If you remove the fetch steps, when would the image be fetched? |
I've been trying to prototype a solution for this. First, a URL and Promise pair: partial interface MediaMetadata {
attribute USVString artwork;
readonly attribute Promise<Response> artworkLoaded;
} Setting Another idea, not implemented, and possibly crazy: partial interface MediaMetadata {
attribute Promise<Response> artwork;
} The API would then be @annevk, advice on how to integrate with Fetch much appreciated! |
There are a few open issues around metadata: w3c#58 w3c#70 w3c#76 In particular the need for feature detection means that we must have an interface, which will be a breaking change. Remove the code until this is more clear, to not tempt anyone into implementing it. Much of this, in particular the prose and example, can be revived.
There are a few open issues around metadata: w3c#58 w3c#70 w3c#76 In particular the need for feature detection means that we must have an interface, which will be a breaking change. Remove the code until this is more clear, to not tempt anyone into implementing it. Much of this, in particular the prose and example, can be revived.
A MediaMetadata object can be created either with a URL or with an existing Response object. This will allow the result of a single fetch() to be used both in MediaMetadata and e.g. for an in-page <img>. Fixes w3c#58
We need to resolve this in order to put artwork back in the spec. Currently, I'm thinking that the But, how do we make prefetching the artwork load? The best I can come up with is a @annevk, thoughts on Fetch integration would be much appreciated. At one point I was thinking that the |
@annevk replied (I asked on the wrong issue at first):
|
The simple options when going with artwork as a URL are:
|
Do you mean |
Did you check what iOS and Android do? |
Yes, @doomdavve took a close look at the iOS and Android APIs when we were starting this. IIRC, both allow you to either give a URL or a handle of sorts to a decoded image. We'll be implementing it by passing a decoded image, so that gives us rather a lot of freedom in how the web-exposed bits look. I'm leaning towards just going with an URL for now and not defining when the fetch steps are invoked, just what they do. Do you think it would be preposterous to later add |
I think for preloading you'd use https://w3c.github.io/resource-hints/. |
Thanks, I knew that was a thing but it still didn't come to mind! There's also https://w3c.github.io/preload/ and it looks like something like this might work: var metadata = new MediaMetadata({ artwork: "artwork.jpg" });
var res = document.createElement("link");
res.rel = "preload";
res.as = "image";
res.href = metadata.artwork;
document.head.appendChild(res); I'm unsure if getting the referrer right might ruin it, @richtr's spec text that I've revived says "no referrer" but I assume that the above would send a referrer. Is there a way to inhibit that? The |
Hmm, per w3c/webappsec-referrer-policy#15 that should have been fixed. |
right, however, it's not yet implemented nor shipped in chrome |
OK, sounds like the right primitives are in the pipeline, so for #126 I think I'll keep the "fetch steps" as late as possible, and lean on preloading to handle this. Thanks all! |
FWIW, Android doesn't quite work well with URLs for notifications. IMO, it would be better to let the UA decide when to fetch. Ideally, if the web application cares about the artwork being available quickly, it could download it and cache it in a SW so it would work offline and be quick to grab on demand. |
Is this only because the resource is needed in many different sizes, or is the timing of the fetch also a problem? |
Hmm, I should have said "Android APIs". There are these |
@doomdavve has a WIP prototype adding |
Make the artwork spec more like WebApp manifest icons, which has `src`, `type` and `sizes` fields. Fixes w3c#58
Make the artwork spec more like WebApp manifest icons, which has `src`, `type` and `sizes` fields. Fixes w3c#58
Make the artwork spec more like WebApp manifest icons, which has `src`, `type` and `sizes` fields. Fixes #58
It seems highly insufficient UI-wise to not have preloaded the image and a bit of the music file. Since you basically cannot release a player that does not have that, we should make sure that the examples cover it I think, as it might illustrate some API holes as well. (E.g. we might need to have more state on when artwork is loaded and such.)
The text was updated successfully, but these errors were encountered: