andyholmes / valent

Connect, control and sync devices
https://valent.andyholmes.ca
Other
492 stars 16 forks source link

Valent only shows one player from the phone in GNOME #638

Open vixalien opened 3 months ago

vixalien commented 3 months ago

Current Behavior

I have Valent connected to my android phone.

Valent only shows one media player in GNOME calendar popover when I play music on the phone.

For example, you can see in the panel that I only have one player.

image

But when I click on that player, you can see multiple players.

image

It seems only the first one is shown as an MPRIS player.

Expected Behavior

I would expect the 2 players to be visible in the GNOME panel.

Desktop

GNOME Shell

Other Desktop

No response

Operating System

Alpine

Installed from

Nightly Flatpak

Version

nightly

Devices

KDE Connect (Android)

Plugins

MPRIS

Logs

No response

Screenshots

No response

andyholmes commented 3 months ago

Yes, that's intentional.

Valent only exports on media player at a time when in a Flatpak, for two reasons:

  1. That used to be the "free" permission you got from the Flatpak sandbox. I think that might be slightly different now, but I haven't checked in a while.
  2. There are many players with broken behaviour or incorrectly reported by other OS's (e.g. Android). GSConnect employs several extremely flakey heuristics to decide whether a player is real and actually playing, rather than:
    • an audio clip in WebView
    • a browser that leaves a player in an undefined state
    • some sketchy background process of Facebook
    • a player with a 2-second lifetime to play a notification sound

I'm not entirely opposed to changing that behaviour to be configurable, but unlike GSConnect I have zero intention of maintaining bizarre heuristics to handle weird stuff other programs or OS's do :slightly_smiling_face:.

I'd want some good design, UX and testing for that though. I'd like to say "sure, users can suck it up if their players are broken", but that's not how issue trackers work :wink:.

EDIT: if that's a thing you might want to work on (with no rush or time-limit), we can create a discussion to do mock-ups, testing, etc.

vixalien commented 3 months ago

Ah I see. The only issue is that for some reason the first player is always called "Google" and it's annoying that I can't see the actual music playing through other apps.

Maybe at least exposing only the latest played source would be better.

andyholmes commented 3 months ago

Maybe at least exposing only the latest played source would be better.

That should be current result, unless the "Google" player starts first and never stops:

https://github.com/andyholmes/valent/blob/28e59d66ba3821a516a797763c152d03db3f9aa6/src/plugins/mpris/valent-mpris-adapter.c#L63-L85

I'm assuming "Google" is something on an Android phone? This sort of falls under the banner of media players and other OS's doing weird things. I'm assuming that if kdeconnect-android could detect this it wouldn't expose the player at all, but maybe it just needs a hard-coded exception on the app-side.

vixalien commented 3 months ago

Yup it's probably something on my Android phone. The thing is that I can't see any other player in the media players so I can't close it.

It shows no track playing and no duration

andyholmes commented 2 months ago

I suppose the exporter could try to prioritize the most recent player to start playing. It occurred to me that's how the media keys in GNOME probably work.

It's possible the same situation might happen in reverse, but I've never had the media keys on my laptop act on a player I didn't expect.

vixalien commented 2 months ago

After some thinking, I think this is the best solution:

I'm assuming that if kdeconnect-android could detect this it wouldn't expose the player at all, but maybe it just needs a hard-coded exception on the app-side.

The "Google" player is not visible in the Android UI, so it shouldn't be visible in kde connect either.

vixalien commented 2 months ago

But something that could possibly help is hiding players with a duration of 0. I don't know if that will affect like livestreams, but what I noticed is that the Google player doesn't have a duration or audio position.

This also happens with YouTube when I'm playing Shorts:

image

But still the best soluion would be to fiix that in KDE Connect

andyholmes commented 2 months ago

But something that could possibly help is hiding players with a duration of 0. I don't know if that will affect like livestreams, but what I noticed is that the Google player doesn't have a duration or audio position.

Yeah, at least in MPRIS only the mpris:track_id is required (which we don't support yet, I believe). I expect 0 is a pretty common fallback to return if mpris:length is missing or for other platforms like Android and Media Session API.

andyholmes commented 2 months ago

Oops. Sorry, I guess the patch doesn't really close the issue 🙃