jacklandrin / OnlySwitch

⚙️ All-in-One menu bar app, hide 💻MacBook Pro's notch, dark mode, AirPods, Shortcuts
https://jacklandrin.github.io/macos%20app/2021/12/01/onlyswitch.html
MIT License
4.04k stars 189 forks source link

media keys for radio #36

Closed WladyX closed 2 years ago

WladyX commented 2 years ago

would it be possible to implement the media keys control for radio? play/pause? thank you for this great app!

jacklandrin commented 2 years ago

Thx for your good suggestion. I'll consider adding this feature.

jacklandrin commented 2 years ago

@WladyX I've researched some solutions, listening media keys to control will conflict with Apple Music and web video. So before I finding better way, the temporary solution is that you can set other hot keys for radio.

jacklandrin commented 2 years ago

@WladyX I know how to figure out it now.

WladyX commented 2 years ago

Cool, you can also get inspiration from this project i think: https://github.com/SokoloffA/radiola

jacklandrin commented 2 years ago

@WladyX yes, I just added togglePlayPauseCommand target to MPRemoteCommandCenter, then I found it works. Now I try to add next/previous feature for radio, like this you can change stations in your list by media keys. All feature will release in version 2.3.3.

jacklandrin commented 2 years ago

@WladyX version 2.3.3 has released.

WladyX commented 2 years ago

Hey @jacklandrin, I've upgraded to 2.3.3 but the media keys do nothing for me, in radiola they work ok (play/pause) :) I've quit radiola, but onlyswitch does not pick up the key press it seems. Can I troubleshoot somehow in order to help you debug?

jacklandrin commented 2 years ago

@WladyX You can check your control center to see which player is prior. The media keys only control the prior player. In macOS, the latest opened player will be the prior player.

WladyX commented 2 years ago

Radiola does not even show up in control center. I see ony onlyswitch there. Anyway, I've closed both, reopened oneswitch, still does not work :)

jacklandrin commented 2 years ago

radiola's solution is listening the keyboard, that will conflict with other player in control center's now playing. When press play button, perhaps, radiola and other player play sound in same time. But in your case, I suggest you can check if now playing function works. You can open a Youtube video, then press media keys to test if it works.

WladyX commented 2 years ago

I cannot control youtube from the media keys it seems...

jacklandrin commented 2 years ago

I'm not sure whether it's a bug of macOS. I developed this feature on macOS 12.4 and also tested it on 13.0. You can try to restart Mac. If your macOS is old version(less than 12.4), you can try to upgrade it.

I found that similar issue is reported in macrumors forum. https://forums.macrumors.com/threads/now-playing-on-menu-bar-issue.2333647/

I hope it's useful for you.

WladyX commented 2 years ago

I found this thread: https://www.reddit.com/r/MacOS/comments/knwj84/media_keys_and_control_center_apple_music_do_not/ and tried launchctl load -w /System/Library/LaunchAgents/com.apple.rcd.plist and this solved my issue, now onlyswitch media keys work! Thank you so much for helping with this!

WladyX commented 2 years ago

I'm pretty sure I disabled that service in order to get rid of Music app when i connected my headphones :))