th-ch / youtube-music

YouTube Music Desktop App bundled with custom plugins (and built-in ad blocker / downloader)
https://th-ch.github.io/youtube-music/
MIT License
8.89k stars 500 forks source link

youtube-music app is overriding my media controls #647

Open typinghands opened 2 years ago

typinghands commented 2 years ago

The youtube-music app is overriding my media controls (play/pause for example), so that I can't actually play or pause a more recent media if there is music playing in the background (it will just pause the music).

This is a problem for my user scenario since I would often listen to music in the background, while watching lectures or other video lessons that I need to quickly pause/unpause to take notes (and I use keyboard shortcuts to do so).

Is this intended behaviour, and is there any way to stop this overriding from happening?

I can confirm that I can usually do this with the normal browser version of youtube music.

Araxeus commented 2 years ago

Do you have shortcuts plugin option Override MediaKeys options activated?

if not then the application doesn't actually do anything related to mediakeys, its all native youtube+electron behavior

typinghands commented 2 years ago

Ok so i have tested a bit with that: initially I had the "Override Mediakeys" OFF, and it was overriding the keys as described in the OP.

Now I have tried with "Override Mediakeys" ON and the behaviour is a bit inconsistent now: I can pause the latest media played with the media keys on my mouse and on my headphones, but the regular 'media keys' on the keyboard and another keyboard shortcut I have set with autohotkey to Play/Pause media will also still get overridden (they can only control music).

The situation is a bit better now, but ideally the keyboard shortcuts were actually the ones I needed the most, to reliably pause lectures while I'm typing notes.

Do you have any idea why this might be happening? It seems they might not be using the same kind of 'media' keys maybe.

I don't know if it's related at all, but I also can't use the options on the Shortcuts > Set Global Song Controls, as they only show me a white box that I can't interact with (screenshot): https://i.imgur.com/jzfTDqV.png

Araxeus commented 2 years ago

I don't know if it's related at all, but I also can't use the options on the Shortcuts > Set Global Song Controls, as they only show me a white box that I can't interact with (screenshot): i.imgur.com/jzfTDqV.png

sorry about that, it was fixed in https://github.com/th-ch/youtube-music/pull/619 but a new version including this fix has yet to be released. (@th-ch is the project owner) meanwhile to fix it you can enable the in-app-menu plugin

typinghands commented 2 years ago

Indeed enabling 'in-app-menu' made the options in Global Song Controls usable. Although even trying to add a new shortcut in there, didn't solve the media overriding issue.

I wonder what is different in the way the app is handling media keys compared to the standard browser version. If there is something that I can test to try to solve this issue I would be happy to try. I don't know if this is happening only on my machine either, because I don't have another pc to test it with atm.

typinghands commented 2 years ago

I have also noticed this behaviour happening in AIMP player actually, I have just tested it. Indeed it seems to 'steal' the media keys as well even if a more recent app is playing media. It might be something in the way windows handles these things, but I don't know if it's possible to make it so that it's the last media played that would get paused/resumed?

typinghands commented 2 years ago

I was wondering if an alternative solution would be feasible: would it be possible to add an (optional) setting to disable YT Music from responding to the normal media keys, and to only respond to the custom shortcut we set on 'Global Song Controls'? (so for example it would not play songs when I press media key play, but it would play it if I press say ALT+P, which would target only YT music now).

SomeAspy commented 1 month ago

This reminds me of https://github.com/ArmCord/ArmCord/issues/403 - Might be worth taking a look. Perhaps add an option to enable these flags. https://github.com/Vencord/Vesktop/blob/aae4223294783e0bd9edb2f7ede3615bac89c231/src/main/index.ts#L38-L43

    // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.
    // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
    app.commandLine.appendSwitch(
        "disable-features",
        "WinRetrieveSuggestionsOnlyOnDemand,HardwareMediaKeyHandling,MediaSessionService"
    );