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

Feature Request: Map shortcuts to media keys #8

Open
sollymay opened this issue Jul 15, 2020 · 13 comments
Open

Feature Request: Map shortcuts to media keys #8

sollymay opened this issue Jul 15, 2020 · 13 comments

Comments

@sollymay
Copy link

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.

@sollymay
Copy link
Author

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.
image

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).

image

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 😄

@sollymay
Copy link
Author

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?

@MarcusTomlinson
Copy link
Member

MarcusTomlinson commented Aug 12, 2020

Hey @sollymay, thanks for the info! I‘ll try look into this over the next couple weeks.

@MarcusTomlinson
Copy link
Member

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.

@vcekron
Copy link

vcekron commented Oct 6, 2020

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.

@sollymay
Copy link
Author

sollymay commented Oct 15, 2020

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

@vcekron
Copy link

vcekron commented Oct 20, 2020

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.

@sollymay
Copy link
Author

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?

@Mittler1
Copy link

In relation to this, I wonder whether a notification, similar to that of Rhythmbox, where you could control apple music, would also be possible:

Screenshot from 2021-06-28 09-20-02

@ghost
Copy link

ghost commented Sep 6, 2021

Any progress on this issue?

@magikid
Copy link

magikid commented Oct 26, 2021

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.

@nbolton
Copy link
Contributor

nbolton commented Oct 18, 2023

Seems there has been no activity on this for a couple of years. Is there still interest in getting this fixed?

@magikid
Copy link

magikid commented Oct 19, 2023

Yes

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

6 participants