MPRIS: Media keys (play, pause etc.) get confused and stop working

Questions about codecs, DVD playback, web plugins...
Forum rules
Before you post please read how to get help
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

Hey guys! I'm sure I'm not the only one with this problem...

On my laptop, I have assigned the shortcut Shift+Alt+/ to play/pause media, while on my desktop, the keyboard has its own media keys. They work fine as long as only one MPRIS-capable app is open at a time, e.g.: Audacious, Opera with an open YouTube tab, Spotify.

Image

But when more than one such app is running, the keys often get confused and stop working until I reboot.

Have you encountered the same problem? Is there a way to restart/reset the MPRIS service without rebooting?
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

Is this really only happening to me?
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

Hi The Bright Side.

I have no experience with MM keys yet. You might want to try removing your shortcut and see if the issue remains. When I'm watching videos in a player I use the Space bar as a Pause/Play button with no assigned shortcut necessary. That will not typically work in browsers though.

Instead of rebooting next time there's an issue, see if deleting the files in ~/.config/pulse then running pulseaudio -k in the terminal fixes it. You'll probably need to restart the player after that.

Good luck.
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

Hey MrEen, thanks kindly for your reply. I've already tried restarting PA and changing/removing the keyboard shortcuts, but to no avail. Thanks for your suggestions though, next time it happens I will give deleting the files a shot - I haven't tried that before.

All in all, it's no a horrible issue, since as you say, a simple mouse click on the player's try icon to bring up the UI followed by Space Bar does the same thing ;-)
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

I'm just not certain where the issue may lie. If it's pulseaudio, the above may work. If it's alsa, you may need to try sudo alsa force-reload. Then again, it could be evdev or equivalent which is something I have basically no experience fiddling with.

I'm hoping one of those commands works for you, and I'm somewhat suspecting pulseaudio is the one getting confused and messing up its own config files.
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

Yeah, next time it gets stuck I will try those commands and report back here for sure. Thanks for your suggestions!
inedibly_indelible
Level 1
Level 1
Posts: 20
Joined: Wed Apr 01, 2015 6:27 am

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by inedibly_indelible »

I am also having this problem.

If I have only Spotify open, everything works great. Play, pause, next track, etc all work as expected.

If I then open VLC, the media keys only work with VLC.

If I then close VLC so only Spotify is open, the media keys don't work at all.

I have tried the following:

- sudo alsa force-reload
- closing all applications which could use media keys, then opening only one, eg Spotify.
- removing and re-adding the media key shortcuts in the System Settings GUI.
- deleting the files in ~/.config/pulse then running pulseaudio -k in the terminal
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

Hi inedibly_indelible.

Could you run this script and post the URL it'll give on the last line please:

Code: Select all

curl https://gitlab.freedesktop.org/pulseaudio/pulseaudio/raw/master/src/utils/pa-info?inline=false | bash | nc termbin.com 9999
That will show a somewhat thorough overview of your sound setup, and I have a suspicion I know where the issue is, but don't know what it's named.
inedibly_indelible
Level 1
Level 1
Posts: 20
Joined: Wed Apr 01, 2015 6:27 am

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by inedibly_indelible »

MrEen wrote:
Mon Mar 02, 2020 7:58 pm
Hi inedibly_indelible.

Could you run this script and post the URL it'll give on the last line please:

Code: Select all

curl https://gitlab.freedesktop.org/pulseaudio/pulseaudio/raw/master/src/utils/pa-info?inline=false | bash | nc termbin.com 9999
That will show a somewhat thorough overview of your sound setup, and I have a suspicion I know where the issue is, but don't know what it's named.
Just pm'ed you the URL. Thanks for looking into this, it seems like such a weird bug.
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

Thanks for that inedibly_indelible.

And surprise! I suspected that this was going to be a Cinnamon issue because the item I was looking for was something named similar to csd-multimedia-something, but of course you are using MATE.

There was nothing close to that cinn entry from your system, but there was this in the same area:

Code: Select all

Client #2
	Driver: protocol-native.c
	Owner Module: 12
	Properties:
		application.name = "MATE Volume Control Applet"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "32"
		application.id = "org.mate.VolumeControlApplet"
		application.icon_name = "multimedia-volume-control"
		application.version = "1.22.0"
		application.process.id = "2053"
		application.process.user = "xxxxx"
		application.process.host = "xxxxxxxx"
		application.process.binary = "mate-volume-control-applet"
		application.language = "en_US.UTF-8"
		window.x11.display = ":0"
		application.process.machine_id = "lettersandnumbershere"
		application.process.session_id = "c2"
The best suggestion I can make is the next time it happens, see if running this in the terminal fixes it:

Code: Select all

killall mate-volume-control-applet && mate-volume-control-applet
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

If the previous post leads to solving the issue (well, a workaround really as there's still an issue that causes it to fail) this is what I was thinking of for Cinnamon users:

Code: Select all

Client #6
	Driver: protocol-native.c
	Owner Module: 11
	Properties:
		application.name = "Cinnamon Volume Control Media Keys"
		native-protocol.peer = "UNIX socket client"
		native-protocol.version = "32"
		application.id = "org.gnome.VolumeControl"
		application.icon_name = "multimedia-volume-control"
		application.version = "4.2.0"
		application.process.id = "1510"
		application.process.user = "xxxx"
		application.process.host = "xxxx"
		application.process.binary = "csd-media-keys"
		application.language = "en_GB.UTF-8"
		window.x11.display = ":0"
		application.process.machine_id = "lettersandnumbershere"
		application.process.session_id = "c2"
So the related terminal command would be this:

Code: Select all

killall csd-media-keys && csd-media-keys
inedibly_indelible
Level 1
Level 1
Posts: 20
Joined: Wed Apr 01, 2015 6:27 am

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by inedibly_indelible »

Thanks for looking at that!

Unfortunately neither of those commands worked :(

Is there perhaps a logfile I can look at for some hints as to what's going on? I checked syslog and dmesg and nothing stood out to me...
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

I honestly wouldn't have a clue what log file might indicate where this is happening.

As a test, I think this might help. In the terminal enter pulseaudio -k && pulseaudio -vvv (this is going to get large pretty quick, we might need a redirect to the pulseaudio -vvv) then force the issue, with at least one use of the MM keys while they're still working. Maybe we can see what is being sent to pulseaudio when increasing the volume for example, and take it from there.

Yeah, we might want to change the command to pulseaudio -k && pulseaudio -vvv > pulse.txt. After recreating the issue, run pulseaudio -k again and I think that'll stop the logging
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

Hey guys, just wanted to quickly jump in and say thanks for following up on this issue. I lost sight of this thread, even though the problem still occurs for me as well. I won't be home at my PC for a few weeks, but once I am and when I experience the issue again, I will refer to this thread and see how I can chime in. In the meantime, I'm following your conversation.
basmas
Level 1
Level 1
Posts: 1
Joined: Thu Mar 05, 2020 4:20 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by basmas »

I have the exact same problem. I tried the steps above but it also doesn't work for me. It would be amazing if there's a way to get this fixed. Thanks for you help guys!
inedibly_indelible
Level 1
Level 1
Posts: 20
Joined: Wed Apr 01, 2015 6:27 am

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by inedibly_indelible »

MrEen wrote:
Tue Mar 03, 2020 7:39 pm
I honestly wouldn't have a clue what log file might indicate where this is happening.

As a test, I think this might help. In the terminal enter pulseaudio -k && pulseaudio -vvv (this is going to get large pretty quick, we might need a redirect to the pulseaudio -vvv) then force the issue, with at least one use of the MM keys while they're still working. Maybe we can see what is being sent to pulseaudio when increasing the volume for example, and take it from there.

Yeah, we might want to change the command to pulseaudio -k && pulseaudio -vvv > pulse.txt. After recreating the issue, run pulseaudio -k again and I think that'll stop the logging
I wasn't able to kill pulseaudio with -k, even looking up the pid and using kill didn't work as it immediately started a new process somehow.

Code: Select all

user@hangfire:~$ ps aux | grep audio
user    18981  0.6  0.0 884408 11172 ?        S<l  18:36   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    18991  0.0  0.0  14424  1088 pts/0    S+   18:37   0:00 grep --color=auto audio
user@hangfire:~$ kill 18981
user@hangfire:~$ ps aux | grep audio
user    19001  3.5  0.0 884552 11100 ?        S<l  18:37   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    19005  0.0  0.0  14424  1060 pts/0    S+   18:37   0:00 grep --color=auto audio
user@hangfire:~$ killall pulseaudio
user@hangfire:~$ ps aux | grep audio
user    19041  1.0  0.0 158944  3548 ?        Sl   18:38   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    19042  0.0  0.0 158944  3620 ?        S    18:38   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    19045  0.0  0.0 158944   656 ?        Ss   18:38   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    19046  4.0  0.0 252784  9216 ?        D<   18:38   0:00 /usr/bin/pulseaudio --start --log-target=syslog
user    19048  0.0  0.0  14424  1104 pts/0    S+   18:38   0:00 grep --color=auto audio
I had to edit /etc/pulse/client.conf and set autospawn=no to be able to kill it.

I ran pulseaudio -vvv whilst the media keys were working and hit all of them a bunch of times over about 15 seconds. The output is here.

I then stopped pulseaudio -vvv that was running, opened VLC, and confirmed the media keys were no longer working with Spotify. BUT the media keys were actually working! I have no idea what's going on and I'm even more confused now.

I'd be very interested to see if anyone else in this thread can replicate this...
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

I had hoped using the kill and verbose options on the same line would have been fast enough to get around the autospawn. I was wrong, sorry. :oops:

I thought I had found a key event here but I was wrong:

Code: Select all

D: [alsa-sink-ALC233 Analog] alsa-sink.c: Thread starting up
D: [pulseaudio] alsa-sink.c: Requested volume: front-left: 60948 /  93% / -1.89 dB,   front-right: 60948 /  93% / -1.89 dB
D: [pulseaudio] alsa-sink.c: Got hardware volume: front-left: 61397 /  94% / -1.70 dB,   front-right: 61397 /  94% / -1.70 dB
D: [pulseaudio] alsa-sink.c: Calculated software volume: front-left: 65057 /  99% / -0.19 dB,   front-right: 65057 /  99% / -0.19 dB (accurate-enough=yes)
I think that's just setting the volume close enough to where it was when you killed PA. Otherwise, there's nothing I spotted in the output showing the use of the keys. However, I'm wondering if PA was even running after you hit Ctrl-C, and had working keys in Spotify. I assume it must have been, but I'm not certain.

I'll try to do some research on this and see if I can come up with anything. Also, this weekend I'll install a keyboard that has MM keys myself and see if I can reproduce this.

At the moment, I'm out of ideas.
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

One thing that might help; Does ps aux | grep media return anything useful?

Also, does closing the web browser get the keys working again?
User avatar
MrEen
Level 21
Level 21
Posts: 13059
Joined: Mon Jun 12, 2017 8:39 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by MrEen »

inedibly_indelible, I think this might work for you. I guessed at the wrong thing I'm thinking with this:

Code: Select all

killall mate-volume-control-applet && mate-volume-control-applet
Try instead:

Code: Select all

killall mate-settings-daemon && mate-settings-daemon
This was a known issue with gnome-settings-daemon I believe, and mate-settings-daemon is a fork of it I'm pretty sure. I could be wrong, and it may have been an issue only with gsd-media-keys which the gsd stands for gnome-settings-daemon. I was hoping with the ps aux | grep media we might see something like msd-media-keys which should be the correct thing to kill and restart if it does exist.

Well, I typed out all that, then look what I found: https://github.com/mate-desktop/mate-se ... media-keys

Maybe for your case, the plugin is dying when the keys stop working and we just need to restart it. I can't tell from quickly looking through the source code, but my guess would be running this in the terminal.:

Code: Select all

msd-media-keys
EDIT: Well damn. Now I found this as well: https://github.com/mate-desktop/mate-se ... gins/mpris

I'm not sure which thing is supposed to be in use.
The Bright Side
Level 2
Level 2
Posts: 99
Joined: Thu Jul 12, 2018 3:09 pm

Re: MPRIS: Media keys (play, pause etc.) get confused and stop working

Post by The Bright Side »

MrEen wrote:
Mon Mar 02, 2020 7:58 pm
Hi inedibly_indelible.

Could you run this script and post the URL it'll give on the last line please:

Code: Select all

curl https://gitlab.freedesktop.org/pulseaudio/pulseaudio/raw/master/src/utils/pa-info?inline=false | bash | nc termbin.com 9999
That will show a somewhat thorough overview of your sound setup, and I have a suspicion I know where the issue is, but don't know what it's named.
Hi MrEen! As I'm typing, I have Spotify open and I had Audacious running earlier. Spotify is not responding to any media key presses. I don't quite recall whether I had them open at the same time at one point during this session though.

URL: https://termbin.com/00qx
Post Reply

Return to “Sound, Multimedia, & Codecs”