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

Bug: macOS media-buttons stop working #205

Open
zagoruev opened this issue Jun 18, 2020 · 36 comments
Open

Bug: macOS media-buttons stop working #205

zagoruev opened this issue Jun 18, 2020 · 36 comments
Labels
Bug Something isn't working

Comments

@zagoruev
Copy link
Contributor

app: 1.11.0
macOS: 10.15.5

Looks like upgrading electron causes media-buttons stop working

Downgrading to electron^7.2.4, electron-builder^21.2.0 brings it to life

@zagoruev
Copy link
Contributor Author

electron/electron#24052

@zagoruev zagoruev changed the title 🐛 macOS media-buttons stop working Bug: macOS media-buttons stop working Jun 18, 2020
@adlerluiz
Copy link
Collaborator

Thanks for the info, i will check

@rickpalmeira rickpalmeira added the Bug Something isn't working label Jun 23, 2020
@gfairchild
Copy link

I think I'm experiencing this same bug. When I press my media keys (Mac Das Keyboard), iTunes opens.

@jegornagel
Copy link

The same issue here. When I press any media keys, iTunes opens.

@mingjun97
Copy link
Collaborator

Same issue :)

@brightshine1111
Copy link

Same issue.

App v1.9.0, macOS v10.15.6.

@markpermann
Copy link

Still a problem in 1.12

@adlerluiz
Copy link
Collaborator

On the electron page, they explain what happened

The following accelerators will not be registered successfully on macOS 10.14 Mojave unless the app has been authorized as a trusted accessibility client:
"Media Play/Pause"
"Media Next Track"
"Media Previous Track"
"Media Stop"

Please read this:
https://developer.apple.com/library/archive/documentation/Accessibility/Conceptual/AccessibilityMacOSX/OSXAXTestingApps.html

@markpermann
Copy link

Thanks for your comment - I don't know if I interpreted it correctly but I responded by opening Security & Privacy prefs on my Mac, selecting Privacy, and enabling the app under Accessibility. The media keys still don't work.

image

@haiGodzilla
Copy link

Hello there,
I have the same issue. When I try to use the Play/Pause Button iTunes opens. Next / Previous song doesn't work at all. I'm on the version 1.12.1
Accessibility for ytmdesktop is activated.

Any suggestions?

Cheers,

@JTWilcox
Copy link

+1, exactly what @haiGodzilla said

@cemkucuk
Copy link

Same here with latest version on MacOS 10.14.6 (18G6020)

@adlerluiz
Copy link
Collaborator

I'm investigating this problem, unfortunately for me it's difficult to validate because I don't have a mac, but I'm doing my best to avoid problems

@tex0l
Copy link

tex0l commented Aug 26, 2020

I've tried fiddling with it on my mac, can't make it work with the electron version used.

It's going to be fixed in an upcoming v10.x.x according to electron/electron#24145.

By the way, in your code you forgot to call systemPreferences.isTrustedAccessibilityClient(true) which checks if the app is a TrustedAccessibilityClient (the true argument just prompt a system dialog telling the user where to go an set that if it's not trusted) on macOS, because you can't register media keys if the app doesn't have the Accessibility rights.

@adlerluiz
Copy link
Collaborator

I will implement, thank you

@tex0l
Copy link

tex0l commented Aug 27, 2020

Perfect, if you need me to quickly test your fixes when the newer version of electron is released, ping me.

@juliovedovatto
Copy link

juliovedovatto commented Oct 5, 2020

I made a small experiment here and tested app.isTrustedAccessibilityClient(true) and built locally to test.

if (isMac()) {
    settingsProvider.set(
        'settings-shiny-tray-dark',
        nativeTheme.shouldUseDarkColors
    )
    systemPreferences.subscribeNotification(
        'AppleInterfaceThemeChangedNotification',
        function theThemeHasChanged() {
            settingsProvider.set(
                'settings-shiny-tray-dark',
                nativeTheme.shouldUseDarkColors
            )
            updateStatusBar()
        }
    )
    const menu = Menu.buildFromTemplate(statusBarMenu)
    Menu.setApplicationMenu(menu)

    systemPreferences.isTrustedAccessibilityClient(true); // check if is trusted
}

I can confirm that app shows the prompt and I'm able to allow access on System Preferences, but still not able to use fn key to play/pause songs. Itunes open instead. Not sure if checkDoubleTapPlayPause function is triggered or not. If I try to use the alternative shortcut (CMD+SHIFT+SPACE in my case), it works.

There is no much topics about this problem, every one I found related to same resolution. But it seems this resolution does not work.

@tex0l
Copy link

tex0l commented Oct 6, 2020

@juliovedovatto It depends on the version of electron you used. The media keys don't work on macOS in electron 10.

The fix electron/electron#24145 was merged into master at the end of August, but hasn't been backported to the stable branches yet (10 and 9).

The first electron version in which it was landed is the https://github.com/electron/electron/releases/tag/v11.0.0-beta.1, but electron v11 is still in beta.

@juliovedovatto
Copy link

@tex0l thanks for the feedback. I checked some topics, but I was not sure if they already fixed for the future versions.

I just tested with Electron 11.0.0-beta.11 and worked as expected.

For now it is good for me, I'll use my custom build and keep an eye when they release oficially.

@lsim
Copy link

lsim commented Nov 25, 2020

This is still broken for me in 1.13.0 installed from homebrew. Is there an ETA for a build with a sufficiently new electron? From the above it sounds like the problem is well understood and the fix for it already in the pipeline.

The media keys work fine for me when playing from a youtube music browser tab. As such this app is a non-starter to me. I hope someone will prioritise giving this some love. The app looks promising.

@aschampion
Copy link

Electron v11 was released on 16 Nov and is up to v11.0.3, so presumably the next release will have this fix (although the development branch is still on v10 right now).

@AlejandroRuiz
Copy link

I just tried with the 1.14.0 beta and seems that this got fixed https://github.com/ytmdesktop/ytmdesktop/releases/tag/v1.14.0

@noisymime
Copy link

Working for me also, but for anyone having troubles with the beta you must still have YTM added under Accessibility as per comment: #205 (comment)

I didn't have this added initially and it was a no go.

@coagmano
Copy link

Can confirm that media keys work correctly in 1.14.0.
In my case I had to remove and re-add YTMDP in accessibility settings

@juliovedovatto
Copy link

juliovedovatto commented Feb 17, 2021

Media keys working as expected in 1.14.0. I can finally ditch the custom build I made.

I had to do the same thing that @coagmano did in order to make the media keys to work again, YTMD did not ask for permissions.

@cruzzer
Copy link

cruzzer commented Apr 13, 2021

Can confirm that permission under privacy/accessibility needed to be set in MacOS for the media keys to work. Interestingly the alternate hotkey <cmd + shift + space> worked without.

@iamhenry
Copy link

the beta link for mac worked for me. @AlejandroRuiz thx!

@rjzheng
Copy link

rjzheng commented Aug 3, 2021

Media keys in 1.14.0 stopped working for me after I upgraded to use Big Sur. But the following helped me fix this.

Settings -> Security & Privacy -> Input Monitoring -> Add Youtube Music Desktop App.

@victor-roswell
Copy link

@rjzheng this worked perfectly. Thank you so much! :)

@EloB
Copy link

EloB commented Feb 13, 2023

Is 1.14.0 still concider nightly build? I'm installing through brew and they only have 1.13.0 release. I was thinking to submit latest version if that works but I don't think brew wants unstable versions.

@EloB
Copy link

EloB commented Jul 15, 2023

Can we deploy that ytdesktop to brew? I made a PR can and everything but brew isn't allowing beta versions. So can we deploy a stable version?

@KWall24
Copy link

KWall24 commented Nov 27, 2023

The solution @rjzheng gave appears to not apply to macOS Sonoma. Hitting play/pause just opens Apple Music even with YTMD in Input Monitoring.

@FormalSnake
Copy link

The solution @rjzheng gave appears to not apply to macOS Sonoma. Hitting play/pause just opens Apple Music even with YTMD in Input Monitoring.

I am having the exact same issue.

@FormalSnake
Copy link

it also doesnt appear here
image

@Alipoodle
Copy link
Member

Quick check, does this issue occur in v2 of the applicaiton.

We do not have the isTrustedAccessibilityClient value currently used but we are using the native Chromium logic for Media stuff so this should fix a lot of the problems.

@jaredkotoff
Copy link
Contributor

I haven't experienced this yet on v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
No open projects
Development

No branches or pull requests