Open Bug 1710229 Opened 4 years ago Updated 2 months ago

MPRIS support for multiple media players

Categories

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

Firefox 88
enhancement

Tracking

()

ASSIGNED

People

(Reporter: necauqua, Assigned: razzeee+mozilla)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 4 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

Open two YouTube videos in separate tabs etc.

Actual results:

One of them can be controlled via MPRIS interface, usually the latest one that had its state changed or from the latest focused tab, exact conditions are unknown, but it looks spotty.

Expected results:

Each media source should get a separate MPRIS object so that separate playbacks can be controlled independently.

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core

From reading the MPRIS spec (https://specifications.freedesktop.org/mpris-spec/latest/) , looking at the d-bus behavior and the code, as far as I can tell, it "just" needs to open new d-dbus connections per active tab.

So widget/gtk/MPRISServiceHandler.cpp needs a change to the two times SprintfLiteral(serviceName, DBUS_MPRIS_SERVICE_NAME ".instance%d", getpid()); is used. I would append the id of the tab that's sending that audio.

I would guess a tabId would be best, but I have no idea of firefox internals. I also can't see a straight forward way to get that in that file, but I haven't done cpp in a few years.

Having looked a bit more at the structure, it might not be as simple, as I think the MPRISServiceHandler is depending on the media control buttons - which probably only can handle one instance.

Flags: needinfo?(jmathies)
Attachment #9524386 - Attachment description: WIP: Bug 1710229 - Implement per-tab MediaControlKeyManager → Bug 1710229 - Implement per-tab MediaControlKeyManager
Assignee: nobody → razzeee+mozilla
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9524386 - Attachment is obsolete: true
Attachment #9524386 - Attachment is obsolete: false
Attachment #9524321 - Attachment is obsolete: true

Hi Kolja,

Thank you for your patch! I’ve taken a quick look at your changes and would like to ask a few questions first:

  1. Since different Linux distributions can use D-Bus connections to create virtual interfaces, I think controlling it via a virtual control button is fine. However, when there are multiple D-Bus connections, which connections will be controlled when pressing a physical control key (e.g., keyboard, Bluetooth headset)? Have you tested different scenarios yet? We’ll likely need new tests as well if we plan to support this.

  2. Do any other browsers currently support multiple D-Bus connections?

  3. Have you run the automated tests yet? We need to ensure that adding a new feature doesn’t break existing functionality. You can use mach try fuzzy --preset media-full to run media related tests. In order to push to try, you need to ensure you have the level 1 access.

  4. I still need to think carefully about supporting multiple control interfaces, especially since Firefox is a cross-platform application. We’d like the behavior to be consistent across platforms as much as possible.

I’ll provide more detailed feedback next week — I’m attending a conference this week, so I don’t have much time to dive deeply into this right now. Thanks!

Flags: needinfo?(jmathies) → needinfo?(razzeee+mozilla)

(In reply to Alastor Wu [:alwu] from comment #6)

Hi Kolja,

Thank you for your patch! I’ve taken a quick look at your changes and would like to ask a few questions first:

  1. Since different Linux distributions can use D-Bus connections to create virtual interfaces, I think controlling it via a virtual control button is fine. However, when there are multiple D-Bus connections, which connections will be controlled when pressing a physical control key (e.g., keyboard, Bluetooth headset)? Have you tested different scenarios yet? We’ll likely need new tests as well if we plan to support this.

  2. Do any other browsers currently support multiple D-Bus connections?

  3. Have you run the automated tests yet? We need to ensure that adding a new feature doesn’t break existing functionality. You can use mach try fuzzy --preset media-full to run media related tests. In order to push to try, you need to ensure you have the level 1 access.

  4. I still need to think carefully about supporting multiple control interfaces, especially since Firefox is a cross-platform application. We’d like the behavior to be consistent across platforms as much as possible.

I’ll provide more detailed feedback next week — I’m attending a conference this week, so I don’t have much time to dive deeply into this right now. Thanks!

Hey,

thanks for checking in and the questions:

  1. I've only tested this via media keys on my laptop. And it seems to control the first one, that started playback and even keep that tab in focus, when playback is stopped, but there is more to play, so that you can resume.

I'm a little bit unsure, if that's the behavior we want - I've looked a bit at the focus following you and basically sticking with the last media tab you've opened, but haven't figured that out.

  1. I'm not aware of a browser doing that. It's clearly supported from the POV of the mpris docs https://specifications.freedesktop.org/mpris/latest/#Bus-Name-Policy - those only leave to question, what their definition of an instance is.

  2. I haven't. But I can hopefully spend some time on that.

  3. Understandable, but at least to me (and some other users), this behavior has been pretty annoying. E.g. having google music open listening to music, then you find a youtube video and by mistake start it before stopping the music. Now you need to find the music tab, and can't stop it from the mpris dialogue.

Cheers

Flags: needinfo?(razzeee+mozilla)

Understandable, but at least to me (and some other users), this behavior has been pretty annoying. E.g. having google music open listening to music, then you find a youtube video and by mistake start it before stopping the music. Now you need to find the music tab, and can't stop it from the mpris dialogue.

For this scenario, you could try to enable the pref media.audioFocus.management which will help you automatically pause music tab when you start the youtube video. That pref is about enabling the audio competing so that only one audio tab can be played at a time, it's currently enabled on Android only.

Attachment #9525800 - Attachment is obsolete: true
Attachment #9525801 - Attachment is obsolete: true
Attachment #9525802 - Attachment is obsolete: true
Duplicate of this bug: 2003046

I have made a plugin for firefox for this

Soundtabs it is pending approval. Should help bridge some of this gap.

Severity: -- → N/A
Priority: -- → P3

Sorry had to reupload, also wanted to make the name more easy to find (less crowded)
Media Bridge

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: