Ytmdesktop: Bug: macOS media-buttons stop working

Created on 18 Jun 2020  路  21Comments  路  Source: ytmdesktop/ytmdesktop

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

bug

Most helpful comment

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

All 21 comments

electron/electron#24052

Thanks for the info, i will check

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

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

Same issue :)

Same issue.

App v1.9.0, macOS v10.15.6.

Still a problem in 1.12

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

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

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,

+1, exactly what @haiGodzilla said

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

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

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 https://github.com/electron/electron/pull/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.

I will implement, thank you

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

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.

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

The fix https://github.com/electron/electron/pull/24145 was merged into master at the end of August, but wasn't 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.

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings