steve228uk / YouTube-Music

:musical_note: A Mac app wrapper for music.youtube.com
https://ytmusic.app
MIT License
2.78k stars 202 forks source link

Media keys Next and Previous don't work #33

Open sy6sy2 opened 6 years ago

sy6sy2 commented 6 years ago

Hello!

My Play/Pause media key works well but the next and previous ones don't work with me.

Thank you!

steve228uk commented 6 years ago

@SylvainCecchetto Are you able to let me know your system configuration, whether the Now Playing widget in Notification Centre updates and version of macOS please.

sy6sy2 commented 6 years ago

Hum, just upgrade to Mojave last night and now any of my media keys work :-/ But the Notification Center works well

steve228uk commented 6 years ago

I've updated to Mojave and confirmed that these are working. Ensure no other app is taking control of the media keys.

matheustav commented 6 years ago

Same here (Mojave). Play/pause work fine, previous/next don't :(

@SylvainCecchetto, did you get it to work?

theinfamousmielie commented 6 years ago

Likewise, I'm on Mojave and I don't believe I have any other media-key apps taking control.

The original reported issue here is isolated to the next/previous track keys only (play/pause is just fine)

If something else was taking control of the media keys, play/pause would also not be working, right?

Potentially worth noting is that even when in the app and it has the focus, neither previous/next keys work, and attempting to click on previous/next icons within the notification centre ALSO has no effect. Play/pause works fine across all three situations.

There's definitely something up here, and I can't be 100% sure that it's the app, but I can't see what else it could be.

steve228uk commented 6 years ago

I’m re-opening this and will investigate further. Are you able to check the Now Playing widget in the Notification Centre?

theinfamousmielie commented 6 years ago

"Now Playing" in the Notification Centre for me displays the song name when paused, and "Youtube Music" when playing. Clicking on Play/Pause works fine, but clicking on Next or Previous doesn't do anything other than offer highlight feedback to show that it was clicked.

I've attached a zipped up video of me interacting with it :) I also move my cursor up and interact with the play/pause key (which works) as well as prev/next (which doesn't) on the keyboard.

Screen Recording 2018-11-08 at 14.46.54.zip

Edit: I updated to the lasted macOs (10.14.1) which of course involved a full restart. The first thing I did after logging in was boot up YT music and try the media keys. No difference, unfortunately.

dsakuma commented 6 years ago

Exactly the same behavior reported by @theinfamousmielie about the Notification Center and next/prev keys (Mojave)

midN commented 6 years ago

Mojave now requires app to request "accessibility permissions" in order to manage prev/next, example - https://github.com/simon-fraser/MusicTube-Player

steve228uk commented 6 years ago

@midN Thanks for the heads up!

That's actually only the case if you're not using the API for media centre support. Prior to this apps (like Spotify) would listen for the key inputs from Apple Events which requires accessibility support.

In this case, the issue seems to be my workaround that is required for 10.13 and earlier of looping a silent track in the background to retain control isn't working. I believe it's no longer necessary and I'm going to try removing it for 10.14.

shoginette commented 5 years ago

Same over here :/

I don't have any icon or title in the "taskbar" at the top though, I have to go back to the YTmusic window everytime. All I get are the song notifications in the notification center on the right.

linxydmhg commented 5 years ago

macOs Mojave 10.14.2

Touchbar: Play/Pause works fine. Next/Previous doen't work, but holding them down for long speeds up the audio until releasing. - both if window is in focus or minimized

Right clicking dock item "Next" "Previous" works fine.

rtyshyk commented 5 years ago

Has prev/next issue as well. macos 10.14.2 (18C54)

ghost commented 5 years ago

I found more detail about this bug, in my case when I close application and run it again, hotkeys works fine just once. Reproduce:

  1. command+Q
  2. run YT Music
  3. start some playlist
  4. press "next" - work fine
  5. press "next" - don't work

if it will be useful I can add logs

It feels like buttons "next" and "previous" do not work like global hotkeys because

  1. command+Q
  2. run YT Music
  3. start some playlist
  4. switch to another application
  5. press "next" - don't work
rkoptev commented 5 years ago

Same issue for me.

YT Music app version: Version 1.0.6 (8) Mac OS Mojave 10.14.2

Prev and next media keys not working while play/pause works fine. All I see in the notification centre are next song notifications, there is no any player there.

art-ewantes commented 5 years ago

Same issue for me. YT Music app version: Version 1.0.6 (8) Mac OS High Sierra 10.13.6 Prev and next media keys not working while play/pause works fine. Hope have ideas about how to fix this.

vishwasnavadak commented 5 years ago

same issue here. YT Music app version: Version 1.0.6 (8) Mac OS Mojave 10.14.3

midN commented 5 years ago

You can stop commenting guys, i don't think owner is developing it anymore. Last updates were almost a year ago. They are all outdated and forgotten.

However check https://github.com/lamazingco/playme, this seems to be the only one with working playback keys on latest mac os

BUSHA commented 5 years ago

Find interesting thing "Next" and "Prev" buttons works like forward and rewind, try to press and hold.

BUSHA commented 5 years ago

Do you plan to fix this issue? It's a bit annoying to open app every time I want skip track...

vishwasnavadak commented 5 years ago

I don't think there is an active maintainer for this repo. There is a PR #57 with the fix waiting to be merged.

midN commented 5 years ago

@steve228uk - Could you give someone else write access to start merging PRs at least please?

Stas-Buzunko commented 5 years ago

confirm that https://github.com/lamazingco/playme works, but pay attention to popup about accessibility on Mac, otherwise media keys wont work

ivankovbas commented 5 years ago

The issue is still reproducing. Stop/Start buttons work well, as well as fast forward and fast backward, but I can't skip the song or move to the previous one.

Notification center widget works in the same way(works everything except Next and Previous keys)

macOS version: Mojave 10.14.6 YT Music version: 1.0.6 (8) MacBook Pro (Retina, 15-inch, Mid 2015)

simion commented 5 years ago

Still not working in macOs Catalina

ivankovbas commented 5 years ago

I've just noticed an interesting thing - if I open YouTube music or SoundCloud in Safari it behaves in the same way(play next/prev media keys doesn't work).

It seems it's a safari issue (maybe this app uses something like embedded safari web view to render YouTube music page).

dongsam commented 4 years ago

FYI: using forked and solved version of keiohtani https://github.com/keiohtani/YouTube-Music/releases/tag/1.0.7 is working for me

or alternative using native browser(chrome, safari) with beardedspice with import youtube music rule is working

simion commented 4 years ago

I found a much better solution: Using Chrome:

  1. Go to https://music.youtube.com
  2. Click Options (3 dots) -> More Tools -> Create Shortcut. Make sure you check "Open as window".
  3. Done. Search for "Youtube Music" in your system apps :) It has a dedicated launcher/icon in dock, the window does not have any browser wrapper/toolbars/etc, and all media keys work! And it appears on alt-tab and all that, because it's basically a system app.
eexit commented 4 years ago

Using Chrome:

  1. Go to https://music.youtube.com
  2. Click Options (3 dots) -> More Tools -> Create Shortcut. Make sure you check "Open as window".
  3. Done. Search for "Youtube Music" in your system apps :) It has a dedicated launcher/icon in dock, the window does not have any browser wrapper/toolbars/etc, and all media keys work! And it appears on alt-tab and all that, because it's basically a system app.

Works very well for any webapp.

alternative using native browser(chrome, safari) with beardedspice with import youtube music rule is working

I had issue with the default YT Music rules, and it looks like the imported one did the trick.

Thanks!

korniux commented 4 years ago

I found a much better solution: Using Chrome:

  1. Go to music.youtube.com
  2. Click Options (3 dots) -> More Tools -> Create Shortcut. Make sure you check "Open as window".
  3. Done. Search for "Youtube Music" in your system apps :) It has a dedicated launcher/icon in dock, the window does not have any browser wrapper/toolbars/etc, and all media keys work! And it appears on alt-tab and all that, because it's basically a system app.

But with caveats:

akinnee commented 3 years ago

Same here, rewind and fast-forward keys are not working on 10.15.7 15-inch 2018 Macbook Pro. Pause/play works.

TimOliver commented 3 years ago

Hey folks! I've been playing with this issue for a bit, and while I can explain why it's happening, I don't yet know how to fix it.

So it turns out that macOS has a policy where, whichever app starts playing last is considered the "now playing" app, and it has control over the media keys.

While YT Music is an app (Stop me if I'm going too fast. 🤣), the actual WKWebView it uses to render the website (By Apple's own standards) lives in a separate app process. So when a song starts playing, even though YT Music started it, the WKWebView "app" takes over control of the media keys. So while this process can play and pause, it doesn't have access to any of the YouTube contextual info to know what to do if the user hits "next", so it just doesn't enable those buttons.

Doing some interim research, this looks like a problem other people have had, and apparently even Apple has gone on the record as "This was an intentional implementation detail".

YT Music actually has code to try and fix this. When playing a song, the app itself plays a silence.mp3 audio file in order to try and force the system to give control back to it. This seemed to work on older systems, but hasn't worked recently.

So with that in mind, I'm not sure how to go about fixing this. It would seem the easiest way would be to trick the WKWebView into not assuming control of the playing video, but I have no idea if this is even possible. The "brute force" alternative would be to pull an Electron and bake in our own rendering engine, but that seems like it would drastically blow out the complexity of this app.

In any case, if anyone has any other ideas I may have missed, please feel free to continue the discussion here. :)

Hope that helps!

unbeatable-101 commented 3 years ago

I can use the play and skip keys on my keyboard, just not in the now playing widget

unbeatable-101 commented 3 years ago

Looking through my settings it seems I enabled Accessibility permissions for YT music in Security & Privacy some time ago