Closed Bug 1623715 Opened 5 years ago Closed 5 years ago

Support platform level MediaControl and MediaSession API implementation

Categories

(GeckoView :: Media, task, P1)

task

Tracking

(firefox81 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: alwu, Assigned: esawin)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [geckoview:m79][geckoview:m80][geckoview:m81])

Attachments

(7 files, 1 obsolete file)

Currently, Fenix is using their own media component [1] to implement the media control, but that component can't suppport MediaSession API [2].

We have already implemented the platform-level media control feature on MacOS, Windows and Linux that is also supporting MediaSession API. Using that API means that websites can customize the metadata that would be shown on the virtual control interface and implement the calllback functions when users press media control keys, such as play/pause, next track and previous track.

We need Fenix to define some API to allow us set the metadata on the virtual interface and handle the task of receving/notifying media control keys, then we can implement something like [3] to enable our platform-level media control on Fenix.

[1] https://github.com/mozilla-mobile/android-components/tree/1795ba83459b6ff2f4cd82a547c5cad5bb98ba1e/components/feature/media/src/main/java/mozilla/components/feature/media
[2] https://w3c.github.io/mediasession/
[3] Platform-specific implementation for media control
MacOS
https://searchfox.org/mozilla-central/source/widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h
Linux
https://searchfox.org/mozilla-central/source/widget/gtk/MPRISServiceHandler.h
Windows
https://searchfox.org/mozilla-central/source/widget/windows/WindowsSMTCProvider.h

Hi, Sebastian,
I wonder if GeckoView team has any interest or resource in this topic?
Thank you.

Flags: needinfo?(s.kaspari)

From AC side I'd definitely be interested in working on a new / better media API - there are multiple issues/bugs that we could address. Flagging emily and snorp to see what they think.

Flags: needinfo?(snorp)
Flags: needinfo?(s.kaspari)
Flags: needinfo?(etoop)

Do we want to move to move this bug and discussion to github.com/mozilla-mobile/android-components ?

Flags: needinfo?(s.kaspari)

Yeah, we could do something different here. I guess it depends on how bad we want the DOM API and how it helps the bugs Sebastian is referring to.

Flags: needinfo?(snorp)

Would like to discuss with product after getting some answers here because fixing Media issues is one of the top Fenix priorities.
Sebastian, could we list off some of the bugs we think this would help resolve to get an idea of how high priority this should be?
Snorp, do we have any idea of the GV effort that would be required here?

Flags: needinfo?(snorp)

Agi has already started looking at this, but I'm not sure it will solve the problems you're referring to. This bug is about a new DOM API which allows Web content to expose an API allowing external control. We might be able to solve some existing problems with the MediaElement GeckoView API by emulating this new DOM API, but it's not clear to me yet.

Flags: needinfo?(snorp) → needinfo?(agi)

It will solve some bugs since the code paths are different (e.g. the notification for soundcloud.com would work), I would like to avoid investing a lot in MediaElement so if any of the bugfixes require big changes I would rather implement the Media Session API and make sure the case works there. I guess I would need to see the list of bugs to know whether this can help or not.

Flags: needinfo?(agi)

Agi, Alastor: Does it make sense to have a very brief meeting this week to discuss the API and what issues we are facing in AC with the current approaches and whether we can create something that fits more the needs we have? The TL;DR is that we jump through a lot of hoops trying to figure out which tab is actively playing (or paused) and whether it is worth exposing controls for it, requesting media focus or showing a media notification. Some of those things desktop already does (better than us) and I would love to just re-use that if we can find a way to expose this nicely as a GeckoView API.

Flags: needinfo?(s.kaspari)
Flags: needinfo?(alwu)
Flags: needinfo?(agi)

I think it makes sense to meet! I've been looking at simplifying that API to make your job simpler and fix some of the problems you mention, here's the draft doc: https://docs.google.com/document/d/1cv7dhLvf7HYr34qNP7SYBNCARBZ2HFbegRsK4PGZHZQ/edit if you can look at it and tell me what you think I'd really appreciate it!

Flags: needinfo?(agi)

alwu: could you or someone on your team look over the doc in Comment 9 too?

Sure, feel free to send a meeting invitation to me!
In addition, I've left some comment on the doc in the comment9. Thank for documenting that!

Flags: needinfo?(alwu)
Product: Firefox for Android → GeckoView
Depends on: 1634442
Rank: 3
Flags: needinfo?(etoop)
Priority: -- → P2
Whiteboard: [geckoview:m79]
Priority: P2 → P1
Assignee: nobody → esawin
Whiteboard: [geckoview:m79] → [geckoview:m79][geckoview:m80]

Depends on D84189

Depends on D84190

Attachment #9164756 - Attachment description: Bug 1623715 - [1.0] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.1] Add MediaSession API for (DOM) media session control delegation.
Whiteboard: [geckoview:m79][geckoview:m80] → [geckoview:m79][geckoview:m80][geckoview:m81]
Attachment #9164756 - Attachment description: Bug 1623715 - [1.1] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.2] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164756 - Attachment description: Bug 1623715 - [1.2] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.3] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164756 - Attachment description: Bug 1623715 - [1.3] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.4] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164756 - Attachment description: Bug 1623715 - [1.4] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.5] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164757 - Attachment description: Bug 1623715 - [2.0] Add MediaSession API tests. → Bug 1623715 - [2.1] Add MediaSession API tests.
Attachment #9165150 - Attachment description: Bug 1623715 - [3.0] Update changelog. → Bug 1623715 - [3.1] Update changelog.
Attachment #9165430 - Attachment description: Bug 1623715 - [4.0] Fix LinkedList::length() for a const context. → Bug 1623715 - [4.1] Fix LinkedList::length() for a const context.

Depends on D86043

Depends on: 1657224, 1657223
Attachment #9164756 - Attachment description: Bug 1623715 - [1.5] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.6] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164757 - Attachment description: Bug 1623715 - [2.1] Add MediaSession API tests. → Bug 1623715 - [2.2] Add MediaSession API tests.

Depends on D86043

Attachment #9168609 - Attachment is obsolete: true
Attachment #9168215 - Attachment description: Bug 1623715 - [5.0] Add missing media control API for GV implementation. → Bug 1623715 - [5.1] Add missing media control API for GV implementation.
Attachment #9168781 - Attachment description: Bug 1623715 - [7.0] Extract media utility functions. → Bug 1623715 - [7.1] Extract media utility functions.
Attachment #9168782 - Attachment description: Bug 1623715 - [8.0] Move media fullscreen event to JS and extend its metadata. → Bug 1623715 - [8.1] Move media fullscreen event to JS and extend its metadata.
Blocks: 1658937
Attachment #9164756 - Attachment description: Bug 1623715 - [1.6] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.7] Add MediaSession API for (DOM) media session control delegation.
Attachment #9164757 - Attachment description: Bug 1623715 - [2.2] Add MediaSession API tests. → Bug 1623715 - [2.3] Add MediaSession API tests.
Blocks: 1659481
Attachment #9164757 - Attachment description: Bug 1623715 - [2.3] Add MediaSession API tests. → Bug 1623715 - [2.4] Add MediaSession API tests.
Attachment #9165150 - Attachment description: Bug 1623715 - [3.1] Update changelog. → Bug 1623715 - [3.2] Update changelog.
Attachment #9168781 - Attachment description: Bug 1623715 - [7.1] Extract media utility functions. → Bug 1623715 - [7.2] Extract media utility functions.
Attachment #9168782 - Attachment description: Bug 1623715 - [8.1] Move media fullscreen event to JS and extend its metadata. → Bug 1623715 - [8.2] Move media fullscreen event to JS and extend its metadata.
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cd585490e79b [1.7] Add MediaSession API for (DOM) media session control delegation. r=snorp,alwu,geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/ddff358f800e [2.4] Add MediaSession API tests. r=geckoview-reviewers,droeh,snorp https://hg.mozilla.org/integration/autoland/rev/6e7ce9e5f89b [3.2] Update changelog. r=geckoview-reviewers,droeh https://hg.mozilla.org/integration/autoland/rev/47f3eb481909 [4.1] Fix LinkedList::length() for a const context. r=froydnj https://hg.mozilla.org/integration/autoland/rev/4887dea37231 [5.1] Add missing media control API for GV implementation. r=alwu https://hg.mozilla.org/integration/autoland/rev/1b7c3fb0da3b [7.2] Extract media utility functions. r=geckoview-reviewers,owlish https://hg.mozilla.org/integration/autoland/rev/c8ca1d1866e7 [8.2] Move media fullscreen event to JS and extend its metadata. r=geckoview-reviewers,snorp,alwu
Attachment #9164756 - Attachment description: Bug 1623715 - [1.7] Add MediaSession API for (DOM) media session control delegation. → Bug 1623715 - [1.8] Add MediaSession API for (DOM) media session control delegation.
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4ff55894774d [1.8] Add MediaSession API for (DOM) media session control delegation. r=snorp,alwu,geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/a118a4d72bef [2.4] Add MediaSession API tests. r=geckoview-reviewers,droeh,snorp https://hg.mozilla.org/integration/autoland/rev/898972ec680c [3.2] Update changelog. r=geckoview-reviewers,droeh https://hg.mozilla.org/integration/autoland/rev/4361ef84e780 [4.1] Fix LinkedList::length() for a const context. r=froydnj https://hg.mozilla.org/integration/autoland/rev/579df1a653ee [5.1] Add missing media control API for GV implementation. r=alwu https://hg.mozilla.org/integration/autoland/rev/2e7e298cfe27 [7.2] Extract media utility functions. r=geckoview-reviewers,owlish https://hg.mozilla.org/integration/autoland/rev/9704afdeefb1 [8.2] Move media fullscreen event to JS and extend its metadata. r=geckoview-reviewers,snorp,alwu

I just pulled and hit this build error from this bug I think.

6:42.98 In file included from Unified_cpp_widget_android1.cpp:65:
 6:42.98 /home/bclary/mozilla/builds/autoland/mozilla/widget/android/nsWindow.cpp:582:41: error: no member named 'GetState' in
 'mozilla::dom::MediaController'
 6:42.98       PlaybackChanged(mMediaController->GetState());
 6:42.98                       ~~~~~~~~~~~~~~~~  ^
 6:42.98 1 error generated.
Pushed by esawin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3b946d54d6db [1.8] Add MediaSession API for (DOM) media session control delegation. r=snorp,alwu,geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/feecebd57035 [2.4] Add MediaSession API tests. r=geckoview-reviewers,droeh,snorp https://hg.mozilla.org/integration/autoland/rev/8f3b66e90a27 [3.2] Update changelog. r=geckoview-reviewers,droeh https://hg.mozilla.org/integration/autoland/rev/9fad7d603355 [4.1] Fix LinkedList::length() for a const context. r=froydnj https://hg.mozilla.org/integration/autoland/rev/36f1dd6d86c0 [5.1] Add missing media control API for GV implementation. r=alwu https://hg.mozilla.org/integration/autoland/rev/971c63a075e1 [7.2] Extract media utility functions. r=geckoview-reviewers,owlish https://hg.mozilla.org/integration/autoland/rev/e61166c9b808 [8.2] Move media fullscreen event to JS and extend its metadata. r=geckoview-reviewers,snorp,alwu
Flags: needinfo?(esawin)
Blocks: 1666609
Regressions: 1678935
No longer regressions: 1678935
Blocks: 1693584

Moving some media bugs to the new GeckoView::Media component.

Component: General → Media
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: