Closed Bug 1665496 Opened 3 years ago Closed 3 years ago

Enable MediaSession API


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




82 Branch
Tracking Status
firefox82 --- fixed


(Reporter: alwu, Assigned: alwu)



(Keywords: dev-doc-needed)


(3 files)

We're going to enable MediaSession API on Fx82.

We're going to enable MediaSession API by default on Fx82.

As we would enable the pref by default, we don't need to use those ini files to enable the pref explicitly anymore.

Attachment #9176160 - Attachment description: Bug 1665496 - enable Media Session API by default. → Bug 1665496 - part1 : enable Media Session API by default.

Need to update MDN as well.

Keywords: dev-doc-needed
Pushed by
part1 : enable Media Session API by default. r=chunmin
part2 : remove unnecessary .ini files. r=chunmin
part3 : remove Media Session API from experimental features list. r=preferences-reviewers,fluent-reviewers,jaws
Regressions: 1666089

Hi Alastor,
Can you please confirm that this also applies to Firefox Android? There is no specific platform info, so I would normally assume so - but it isn't in the BCD for FF android so wanted to make sure.

Flags: needinfo?(alwu)

MediaSession API would be enabled by default on Fx82 for all platforms, so yes, you can use that on Android as well.

However, on Android, using MediaSession API won't affect the media control on Android, because Fenix is still using their own android component which won't reflect the change from MediaSession API.

They will change to use our platform implementation in order to make that work on Android, but I don't know their exact plan and date.

Flags: needinfo?(alwu)

Thanks Alastor - so basically you're saying it is part of the platform so you won't get errors if you try it .... but you won't actually have the functionality either? I wonder what the best way to capture that in BCD is !

Flags: needinfo?(alwu)

Yes. Does BCD mean browser-compat-data [1]? If so, I think you can say it's compatible on Android. Because in the spec, the spec mentions the user agent [2] can decide which media session is affective. So for now, we can regard all media sessions on Android as non-affective.


Flags: needinfo?(alwu)

Hi Alastor. Yes, I did mean browser-compat-data. I will update appropriately. Thanks for all your help.

Hi Alastor,
Sorry to come back to you. The browser-compat-data needs a little more clarification of what work is missing to allow users to see this API "in action" (i.e. what would need to happen to allow us to set a page using this API as the lockscreen source on Android, or Windows or whatever).
Is it code that is missing in Firefox? Or is it some integration work in Android? Will this work on Windows, MacOS etc?

Flags: needinfo?(alwu)

So this API allows users to customize (1) the metadata that would be shown on the virtual control interface, and (2) the action when users press media keys, such as play, pause.

Virtual control interface

If we want to do (1), then the premise is that the platform has to the ability to show the virtual control interface. On Windows 8.1+, Windows provides a framework SMTC that would show the virtual control interface when users are pressing media key. On GTK based Linux, they support MPRIS that is also a spec for media control, so they can show the virtual control interface as well. On MacOS, only Bug Sur has that ability, other older versions of MacOS won't show the virtual control interface.

For mobile, it's little complicated. As your know, we wrap Gecko into GeckoView, then any application can use GeckoView to build their own browser. So the ability is actually implemented by the embedded applications, eg. Fenix, Firefox reality or any application using GeckoView.

We have exposed a corresponding API on GeckoView [1], so the application has to use that API then integrate the information that website set into their own control interface. Currently, we are still waiting Fenix team to finish that in order to show the metadata on their control interface.


Action handler

On all desktops, users can all set the action handler for the action they want to listen to, and perform the corresponding action when the certain media key is being pressed.

On mobile, same issue as the virtual control interface. It depends on if the application uses GeckoView API.

As based on what Mozilla defines our product, that would be a gap between Firefox desktop (Gecko) and Firefox Android (application using GeckoView). So I would still recommend to mark this API availiable by default on Fx82 for desktops, and add some explanation for why it hasn't work yet on Firefox Android.

Flags: needinfo?(alwu)
You need to log in before you can comment on or make changes to this bug.