Open rashil2000 opened 2 years ago
This would be fantastic! 👍
I've investigated the problem. It seems to me that to have access to the Windows media controls we need to have a "handle to a window" (HWND). Unfortunately ncspot is a terminal app and I didn't find a way to get a handle that works with souvlaki. I've used GetConsoleWindow (which is deprecated) without success.
Hmm, doesn't the example code there seem to be using a console application?
To have a MediaControl
instance (controls
in your example) you have to provide a PlatformConfig
that needs a HWND (https://docs.rs/souvlaki/latest/souvlaki/struct.MediaControls.html#method.new). On Windows it is required as you can see in souvlaki source code.
EDIT: In souvlaki repo it shows an example that uses winit
to create a windows then get a handle from it. The other examples don't show how to get a handle from a console app unfortunately.
Ah, I see...
@itytophile Well getting it working for macOS/Linux systems would still be a win right?
This feels like such a needed feature for a media player app.
@jacksongoode I already have media control on my linux desktop (GNOME) and I thought that the feature was available on macOS. I don't have an apple device to test that out.
@jacksongoode I already have media control on my linux desktop (GNOME) and I thought that the feature was available on macOS. I don't have an apple device to test that out.
Huh, then the controls aren't exposed for macOS.
MPRIS API is only available for Linux.
This issue request is for Windows and macOS support.
Is this on the roadmap @hrkfdn? Global media keys on macOS would be really great.
It seems souvlaki has support for zbus as a backend as well https://github.com/Sinono3/souvlaki#linux-backends-d-bus-and-zbus
Global media keys support would be great for MacOS. Would it also end up showing the album art here?
I've investigated the problem. It seems to me that to have access to the Windows media controls we need to have a "handle to a window" (HWND). Unfortunately ncspot is a terminal app and I didn't find a way to get a handle that works with souvlaki. I've used GetConsoleWindow (which is deprecated) without success.
Couldn't you spawn an invisible window that would grab key events and pass them into ncspot?
Couldn't you spawn an invisible window that would grab key events and pass them into ncspot?
That's how https://github.com/aome510/spotify-player/ approaches media controls.
@jacksongoode Are you working on this? I was thinking of maybe picking this up as an excuse to learn rust.
@ptixed No I'm not, I would go ahead and use that other project to guide you!
Is your feature request related to a problem? Please describe. I see that media control on Linux has been implemented via MPRIS. It would be great to have this functionality on all platforms.
Describe the solution you'd like There's a crate - https://github.com/Sinono3/souvlaki - which abstracts away media control under a unified function. It not only supports Linux (via MPRIS), but also has full support for Windows and macOS.
Describe alternatives you've considered None
Additional context This is what a typical function looks like in souvlaki:
See https://github.com/Sinono3/souvlaki/tree/master/examples for more examples.