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

Media Keys stop working after closing window #43

Closed
alosarjos opened this issue Aug 24, 2019 · 4 comments
Closed

Media Keys stop working after closing window #43

alosarjos opened this issue Aug 24, 2019 · 4 comments

Comments

@alosarjos
Copy link

Hello there!
I'm working on a little desktop Youtube Music App. It uses this library to provide the Metadata and controls on Gnome. When running the app for the first time it works perfectly, but if I close the app window and restart it, the keyboard media keys do not work any more (The notification and the controls there by clicking still work).

By some reason, if I instead close the app by Ctrl+C on the terminal and then open it again, the media keys keep working the next time I open the app.

The only way I found to get the media keys working again once "they are lost" is by closing the session and re-login.

OS: Fedora 30 Workstation
Gnome Version: 3.32.2
Node: 12.9.0
Electron: 6.0.3

@acrisci
Copy link
Member

acrisci commented Aug 25, 2019

The only thing I know about electron is from supporting this library, but I'll take a guess.

I think there are two threads in an electron app, the UI thread and the background thread. My guess is that when you close the window, the UI thread is suspended and resumed which is a case I haven't tested.

If you're running mpris-service on the UI thread, that's probably not going to work. You have to run it on the other thread.

See the implementation examples in #30 and see if you're doing anything different.

@alosarjos
Copy link
Author

I'm running it on the main thread as far as I know. When closing the app with the close button, the process in the terminal (From launching the app from the terminal) also finishes. I've tried getting direct access to the mediaKeys bus in the way GPMDP does here: https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/blob/master/src/main/features/linux/mediaKeysDBus.js

But I'm getting: DBusError: The name is not activatable

@acrisci
Copy link
Member

acrisci commented Aug 26, 2019

You're probably getting that because you're not running the settings daemon. Or maybe it's broken, I don't know. Note also that player uses this library as well.

It sounds to me like the process isn't terminating for some reason. In that case, it will keep the name on the bus. The library is supposed to use another name in that case.

There's nothing I can really do in the library in that case.

You can see all the names on the bus with this command:

dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames

Look for anything with mpris and your player name in it. If it's still there after the window closes, then the process is still running and taking up the name. If it's doing that, you should see another player with the same name and .instance somewhere at the end of it.

@acrisci
Copy link
Member

acrisci commented Sep 5, 2019

I'm going to close this because it sounds more like an electron error than a library error, but if you resolve this or get more info, post here so other people can know how to avoid this issue.

@acrisci acrisci closed this as completed Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants