Closed Bug 1592037 Opened 3 years ago Closed 3 years ago

Add MediaController API to set media metadata

Categories

(Core :: Audio/Video: Playback, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox75 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

Details

Attachments

(7 files)

Now I'm thinking about exposing methods on MediaController to allow us set media metadata, and create a generic interface, which would be used in MediaController, as an abstract layer in order to use platform-specific API to set the metadata's infomation on the visual controller interface, for example, MPRIS on Linux, SMTC on Windows, MediaController on Android.

Now I'm implementing this one, and it's based on the work of bug1592454.

Blocks: 1592454
Depends on: 1606782
Depends on: 1610723

Now I'm working on it, but I don't know if I can successfully fix it in this release cycle, so I would target this in the next cycle for now.

Priority: P2 → P3

emplace can only be used on an empty Maybe, but in our case, we can update the metadata anytime even if we have set the metadata before, so using Some() is actully the right way.

Attachment #9129920 - Attachment description: Bug 1592037 - part6 : implement a chrome-only method for accessing current active media metadata. → Bug 1592037 - part6 : implement a chrome-only method for accessing current active media metadata during testing.
Attachment #9129914 - Attachment description: Bug 1592037 - part1: do not update empty metadata to media session controller. → Bug 1592037 - part1 : do not update empty metadata to media session controller.

Here is a short brief-up for what I've done in this bug and why we need these patches.


For the media control, some platforms would display a system level virtual media control interface to allow user control media directly without opening a specific application. On that interface, we would have some control buttons, such as play/pause, prev song and next song, and the metadata information that would show what media user is currently playing. The metadata might contains artist title, album name and album cover.

Currently we would show this kind of control interface on Windows and Linux (Android is using their own Android component so it's not related what we do here), so we would like to implement a method on the MediaControlKeysEventSource, that is an interface which we use to encapsulate the details of handling media keys on different platforms, to allow each platform to set metadata via platform specific API.

In addition, MediaSession API provides a way to allow website to customize their own metadata [1]. In this bug, we would propagate that metadata to the media controller in the chrome process, and then update that metadata to the MediaControlKeysEventSource in order to display metadata on the virtual media controller interface.

If the website which is playing media doesn't use MediaSession API, or the media session it uses doesn't contain any metadata or an empty metadata [2], then we would generate a default metadata, which would use website's title as artist name and default favicon icon as an artwork.

[1] https://w3c.github.io/mediasession/#examples
[2] https://w3c.github.io/mediasession/#empty-metadata

Attachment #9129915 - Attachment description: Bug 1592037 - part2 : use `Some` to replace `emplace()`. → Bug 1592037 - part2 : use `Put()` to replace `emplace()`
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0f698a08a024
part1 : do not update empty metadata to media session controller. r=MeFisto94
https://hg.mozilla.org/integration/autoland/rev/5e8de6ea0c6e
part2 : use `Put()` to replace `emplace()` r=MeFisto94
https://hg.mozilla.org/integration/autoland/rev/06edd39ee3a0
part3 : notifty updating media session's metadata. r=MeFisto94
https://hg.mozilla.org/integration/autoland/rev/b27118f20ad5
part4 : update metadata to the event source. r=MeFisto94
https://hg.mozilla.org/integration/autoland/rev/0a99bf156346
part5 : make sure we send `main-media-controller-changed` everytime the main controller is changed. r=MeFisto94
https://hg.mozilla.org/integration/autoland/rev/436c85047eaf
part6 : implement a chrome-only method for accessing current active media metadata during testing. r=bzbarsky
https://hg.mozilla.org/integration/autoland/rev/79eed382da77
part7 : add metadata test. r=MeFisto94
You need to log in before you can comment on or make changes to this bug.