-
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
Should it be possible to set the MediaMetadata attributes? #116
Comments
I'd say both designs are valid. As usual the mutable version adds more complexity, both for implementation and for authors to keep track of. But it does give some convenience. I guess I would add mutability and a corresponding pointer back to the parent MediaSession object only if I expected it to be a common use case to update a single property at once. I'm not really sure whether that's true in general. Although you could imagine only updating title if playing an album from the same artist, in practice I think the code will more likely be resetting the metadata on every new track. |
One of the more plausible cases where you would update only the title could be an audiobook with many chapters. You might not have separate audio files for each chapter, just a time cue to update the in-page and external UI. I'm happy to leave this issue open and seek out feedback on this when developers get to play with the API. |
I'm not sure why this would be more complex for authors: it gives them more flexibility which they can use if they want to. Regarding implementation complexity, I think we could say that the UA could start a microtask to update the metadata so we don't end up updating them x times. |
The microtask @mounirlamouri suggested seems the right thing to do there. I even would remove the function updateMetadata(event) {
sharedSession.metadata.title = event.target == audio1 ? "Chapter 1" : "Chapter 2";
}
audio1.addEventListener("play", updateMetadata);
audio2.addEventListener("play", updateMetadata); |
What I think is not good about having |
I understand your point about resetting the session. |
I'm not entirely sure I followed. What I would imagine is something like: partial interface MediaSession {
attribute MediaMetadata? metadata;
};
interface MediaMetadata {
attribute DOMString title;
attribute DOMString artist;
attribute DOMString album;
}; (Note: I would see a benefit in having Reset could be done with |
Nice! partial interface MediaSession {
attribute MediaMetadata? metadata;
};
interface MediaMetadata {
attribute DOMString? title;
attribute DOMString? artist;
attribute DOMString? album;
attribute FrozenArray<MediaArtwork>? artworks;
}; and changing artwork would be as simple as: sharedMediaSession.metadata.artworks = [{ src: "podcast.jpg" }]; |
@foolip @doomdavve would you be fine with this? |
My preference is to let As for There might be an extra problem with having |
@beaufortfrancois WDYT of following the proposal @foolip made in the comment above? |
The "extra" complexity added seems to me less than the convenience it would bring to web developers. |
Spec discussion: w3c/mediasession#116 BUG=674710 R=zqzhang@chromium.org Review-Url: https://codereview.chromium.org/2584703002 Cr-Commit-Position: refs/heads/master@{#439207}
Fixed by #156 |
The metadata proposal in #115 is one where MediaMetadata object are immutable, once created they can only be passed around.
The main reason for this is so that there can be no question about what the following does:
Making the attributes mutable would admittedly make the code simpler if only a single field has to be updated, as otherwise one has to keep the MediaMetadataInit dictionary object around, mutate that, and create a new MediaMetadata object.
If the attributes are mutable, a MediaMetadata object would need a way to notify the MediaSession object on which it is set, so that it updates the metadata at the next microtask checkpoint, or similar.
Issue opened in response to feedback from @mounirlamouri in #115 (diff)
The text was updated successfully, but these errors were encountered: