Feature Request: Map shortcuts to media keys
sollymay opened this issue · comments
hey @McGvG @MarcusTomlinson, it would be great if you could map the keyboard shortcuts to the media keys some way to get play/pause next and previous functionality on this.
Not sure how easy it will be since, from my understanding, the keyboard shortcuts are spacebar and the right and left arrow keys respectively on the apple music web app.
Just checked on changing something slightly to prove a theory I had on the app itself to see if I could make media keys work.
Instead of using chromium, I went for hardcoding chrome to launch the player and lo and behold, media keys work correctly! I know this is not a super clean method but just wanted to understand why this was not working on your end.
I think this is probably a configuration thing or the version of chromium being used for the project, but it also had to do with this icon that appears on the top right corner (where the extensions are), that made it all work. I understand this is not an extension per se as I can't uninstall it, but a core functionality of Google Chrome (https://www.blog.google/products/chrome/manage-audio-and-video-in-chrome/). I looked for examples of getting that configured in chromium but to no avail (however, I think this is doable and much needed for a media player).
Let me know if the investigation process I did could help implement media keys. I really want this feature and want to help you guys with it 😄
I went ahead and installed my own version of chromium (latest available and just replaced the exec to that chromium) and media keys now work!
exec` "chromium-browser" "--no-sandbox" "--app=https://music.apple.com/$cc/browse" "--disable-sync" "--window-size=1000,600" "--user-data-dir=$SNAP_USER_DATA/.config/chromium" "--class=apple-music-for-linux"
Is it possible for you to update to latest chromium on the repo so that this function works by default?
Hey @sollymay, thanks for the info! I‘ll try look into this over the next couple weeks.
Is it possible for you to update to latest chromium on the repo so that this function works by default?
The chromium version in the latest build of the snap is the latest (85.0.4183.83) and shortcuts still don’t work unfortunately.
Is it possible for you to update to latest chromium on the repo so that this function works by default?
The chromium version in the latest build of the snap is the latest (85.0.4183.83) and shortcuts still don’t work unfortunately.
They work just fine with playerctl on my system.
interesting @simokron. I installed playerctl on my system (Elementary OS Hera) and tried to trigger play/pause, next, previous but seems like the apple music player is not being recognized by the system. I'm using Elementary OS Hera, which is based off Ubuntu 18.04. Maybe this has to do with Ubuntu 18.04 not recognizing the player?
Description: elementary OS 5.1.7 Hera
Release: 5.1.7
Codename: hera
Now, if I open music.apple.com by itself in chrome or chromium and not with the snap wrapper, both work with media keys and with playerctl, so seems to be something with the way the snap is built that disables some features for chromium? Just a guess, really not an expert in this
interesting @simokron. I installed playerctl on my system (Elementary OS Hera) and tried to trigger play/pause, next, previous but seems like the apple music player is not being recognized by the system. I'm using Elementary OS Hera, which is based off Ubuntu 18.04. Maybe this has to do with Ubuntu 18.04 not recognizing the player?
Description: elementary OS 5.1.7 Hera Release: 5.1.7 Codename: hera
Now, if I open music.apple.com by itself in chrome or chromium and not with the snap wrapper, both work with media keys and with playerctl, so seems to be something with the way the snap is built that disables some features for chromium? Just a guess, really not an expert in this
Was Chrome or Chromium open when you tried the snap? Normally, playerctl
only applies to the "current" player. You can see how many players are available via playerctl -l
.
Anyway, at the risk of derailing this thread a bit, could you please try playerctl -a play-pause
? That should send the command to all available players.
Other than that, I'm not too sure. It seems to me like it should work, but I'm afraid I'm also not an expert.
I tried playerctl -a play-pause
and it does not work. I then opened another music player and did playerctl -a play-pause
and it worked with that. I also tried with anything on Chrome or with Apple Music straight from Chrome and it worked. I think there might be an issue with the snap or the way it was installed?
Any progress on this issue?
I found this gist which might get the buttons working: https://gist.github.com/twolfson/0c6b8062c712ddabf882.
When on Apple Music, there is a window.audioPlayer
object with some useful functions to pause, play, and control the volume. I haven't found any way to skip a track or go back yet.
Seems there has been no activity on this for a couple of years. Is there still interest in getting this fixed?
Yes