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

add Gnome's MediaKeys support to allow for controlling stremio using media keys #350

Closed
wants to merge 8 commits into from

Conversation

Hazem-Gamall
Copy link

add support for media keys on gnome-based desktop environments, using gnome's dbus MediaKeys interface.

@Hazem-Gamall
Copy link
Author

Description of the solution:

  • Call the GrabMediaKeys dbus method to subscribe to the gnome settings daemon and receive media key inputs from it.
  • Bind a C++ method to the MediaPlayerKeyPressed settings daemon signal, the C++ method takes in the string inputs from the signal, and checks if the application is the proper recipient for the signal.
  • We then emit a signal with the action(media key) received in the previous step, that signal is bound to a qml slot.
  • Currently, the qml slot only checks if the action is Play or Pause and inverts the state of the mpv player, but further actions could be supported in a similar manner.
  • If stremio is no longer visible, we call the ReleaseMediaPlayerKeys, which means we can no longer control the player with media keys. Now this step I don't really know whether it should be implemented or not, as in my experience with it, stremio can keep playing even if it's minimized into the system tray(not visible), so maybe not RelaseMediaPlayerKeys at all?

@t1z14n
Copy link

t1z14n commented Sep 13, 2023

Would it be possible to transfer this to the Windows version as well? Would be greatly appreciated

@core1024
Copy link
Member

Hi. Thank you for the contribution.

Unfortunately this doesn't work on my PC. I tested it first before checking the code. So basically I get this messages in the console:

handleVisibilityChange: 1

GrabMediaPlayerKeys Reply was: invalid

The name org.mpris.MediaPlayer2 was not provided by any .service files
GrabMediaPlayerKeys Reply was: valid

This was strange as I see error and then it says GrabMediaPlayerKeys Reply was: valid but I fund that this is a bug and the valid message is always printed.

Started to dig into the issue I found this merge reqquest which explains why it's not working.

I want to add two very important points.

  1. The Makefile in the root of the repo must do nothing. It's a legacy thing. Something to do with the CI. I don't remember but it must not be changed.
  2. In order this to be done properly MPRIS (Media Player Remote Interfacing Specification) should be used instead of Gnome specific API.

I found an example implementation of MPRIS for Qt and QML which may help implementing this feature.

If you are willing to implement MPRIS I will gladly review and merge the changes.

If you don't have time we may eventually implement it but I am not giving any promises or estimates.

Thank you again.

@core1024 core1024 closed this Sep 19, 2023
@Hazem-Gamall
Copy link
Author

@core1024 thank you for the feedback, i will try to implement it whenever i have some free time.

@TheOverpassArsonist
Copy link

TheOverpassArsonist commented Feb 11, 2024

I was looking into this as well and found https://github.com/hoyon/mpv-mpris which adds seamless support between MPRIS and MPV, which (as far as I remember and can tell with some quick sanity checks) Stremio uses. (through libmpv) Unfortunately, libmpv does not get that seamless integration.

I can't say anything with certainty, but it'd likely be a lot less work to try to get Stremio's libmpv to work with mpv-mpris then have people just install that as an optional dependency then try to implement mpris by hand. It's definitely a suboptimal solution, but I just checked and given how seamless mpv-mpris seems to work, it might be a relatively quick and easy bodge that works well-enough.

edit : FYI as an extremely sub-optimal user-side workaround if you install mpv-mpris and then rightclick inside of stremio and click "watch on MPV" media keys will, sort of, work. Pause/Play seems to work fine, but next and previous don't, and it just closes instead of playing the next episode automatically

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

Successfully merging this pull request may close these issues.

4 participants