Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playerctld: a proxy daemon for the active player #161

Closed
acrisci opened this issue Jan 11, 2020 · 3 comments
Closed

playerctld: a proxy daemon for the active player #161

acrisci opened this issue Jan 11, 2020 · 3 comments

Comments

@acrisci
Copy link
Member

acrisci commented Jan 11, 2020

A lot of people are having trouble managing multiple media players with Playerctl. They would like it to always control the last "active player". This definition needs some fleshing out, but I think it approximates something like the last player to do some action like play, pause, switch track, open, etc.

This cannot be accomplished with a one-off command because we don't have access to the history of player actions. It could be accomplished if we had a daemon running to monitor player actions and contain the logic to determine what is the most active one.

To accomplish this, we could add a new binary to Playerctl called playerctld. This should be activatable so it can be launched on demand by Playerctl (dbus supports this I think).

The daemon will implement org.mpris.MediaPlayer2.Player as a proxy to the active player. So calling Play on this interface will cause the active player to play by calling that method on the player and returning its result.

If we take the name org.mpris.MediaPlayer2.playerctld, we can integrate this functionality into Playerctl without any modifications to the main binary, except maybe to activate the service on demand.

playerctl --player playerctld play

In this case, playerctld will give the command to whatever it decides is the active player.

More interfaces could be added to playerctld at a later time to facilitate third-party widgets and other desktop tools to better integrate with Playerctl and the desktop.

Feedback on the approach is welcome.

@maximbaz
Copy link

Just some feedback, this works really well, thank you very much!

kdesysadmin pushed a commit to KDE/kdeconnect-kde that referenced this issue May 20, 2020
playerctld (altdesktop/playerctl#161) is a proxy daemon for the currently active player by playerctl, which facilitates managing mpris players, forwarding requests to the currently active/last active player, and sorting out troubles with selecting the correct player manually.
Unfortunately, it also creates an annoying issue with kdeconnect: when playing media on the phone, kdeconnect publishes the state to the computer through the mprisremote plugin - then, playerctld picks it up as active player, and registers its own mpris media player. As a result, the mpriscontrol plugin sees this as a running media player, and in turn, publishes the state back to the phone, essentially creating another media session on the phone, resulting in two notifications. As playerctld is _always_ only a proxy to another media player (or kdeconnect), it can safely be ignored, just like kdeconnect itself already is. This commit adds an if check doing exactly that.
@danielkrajnik
Copy link

Before I learnt about this daemon a zenity prompt with a list of available players that was saved to a file and read on each playerctl invocation was my solution, but will definitely give playerctld a try now.

@v4u6h4n
Copy link

v4u6h4n commented Jan 22, 2024

Thankyou!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants