Google-play-music-desktop-player-unofficial-: Make Windows 10 Media Service compatible with Native Media Keys

Created on 24 Mar 2017  路  33Comments  路  Source: MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-

OS: Win10

Issue Descriptions: Media Keys skip twice if W10 Media Service is enabled.

Steps to Reproduce: Enable W10 Media Service, push an actual media key

According to previous Issues you implemented a "fix" so that media keys don't double-skip tracks.

Apparently that fix was to disable the W10 Media Service. But I'd actually like to be using that, this seems more of a workaround then an actual fix. Because the error reappears if I use the W10 Media Service popup.

statuhelp-wanted statuwontfix

Most helpful comment

See #2253

First off, I don't appreciate the tone of this issue, it is uncalled for and somewhat insulting to the effort I put into this player. I would appreciate a much more reasonable tone from here on out please. Although I don't have a CODE_OF_CONDUCT on this repository I do expect that reporters treat maintainers with respect and respect will be given back.

As to your actual issue as I have said on numerous other issues there is not a definitive or reliable way to only use the W10 Media Service and not global shortcuts. Global shortcuts catch everything, even when games are full screen or apps like Netflix take control of an entire display. W10 Media Service events are only dispatched if the currently active program allows them to be which means that certain applications either by shoddy design or bad internal logic prevent the keys from propagating.

Perhaps this should be a user decision, which strategy do they want to use for media keys, but that is not something I am prepared to support myself. This application is supposed to be simple with minimal options but maximized customizability. Adding an advanced concept like Low Level Keyboard Listeners VS Media Service will confuse users and result in a whole bunch of "I changed this option and now it doesn't work" issues when the answer will be "change it back....".

It it's current situation everything works by default and I don't want to change that. If someone can propose or even better implement a "working everywhere" setup for Media Service + Global Shortcuts working at the same time without the double event issue then I will gladly look into this more. Until then this is a wontfix from me.

All 33 comments

See #2253

First off, I don't appreciate the tone of this issue, it is uncalled for and somewhat insulting to the effort I put into this player. I would appreciate a much more reasonable tone from here on out please. Although I don't have a CODE_OF_CONDUCT on this repository I do expect that reporters treat maintainers with respect and respect will be given back.

As to your actual issue as I have said on numerous other issues there is not a definitive or reliable way to only use the W10 Media Service and not global shortcuts. Global shortcuts catch everything, even when games are full screen or apps like Netflix take control of an entire display. W10 Media Service events are only dispatched if the currently active program allows them to be which means that certain applications either by shoddy design or bad internal logic prevent the keys from propagating.

Perhaps this should be a user decision, which strategy do they want to use for media keys, but that is not something I am prepared to support myself. This application is supposed to be simple with minimal options but maximized customizability. Adding an advanced concept like Low Level Keyboard Listeners VS Media Service will confuse users and result in a whole bunch of "I changed this option and now it doesn't work" issues when the answer will be "change it back....".

It it's current situation everything works by default and I don't want to change that. If someone can propose or even better implement a "working everywhere" setup for Media Service + Global Shortcuts working at the same time without the double event issue then I will gladly look into this more. Until then this is a wontfix from me.

@MarshallOfSound, I've been looking into this issue and I'll keep posting updates on my progress in issue #2253, unless you would like me to move the discussion to this issue.

@Kytech Let's put it in here, closed issues are hidden from my priority notifications

Out of curiosity, is this related to an issue I've been having, where Windows will periodically not intercept media key presses at all? I came to report that, but decided it best to try commenting on an existing issue first.

Basically, I have media keys on my keyboard and my headphones, but GPMDP sometimes doesn't pick up on them. It's an instance-based issue, in that it either works or doesn't work, from the time the program starts until it closes (never waffles while the program remains open). I think it also is affected by whether the program launches during start up (possibly this is more to do with launching before other programs), or while Windows is running, or restoring from suspension/sleep.

Restarting the program when it's not responding to media keys does not reliably resolve the issue.

I've tried toggling a few things in the settings menus, but haven't been able to find a way to return the functionality in a predictable way. So I have a feeling either it's a genuine bug, or reliant on a Windows service that is malfunctioning or being preempted by another program.

I can provide additional information if you have any questions.

As always, thanks so much for the work you do on this @MarshallOfSound. I love this program and use it all the time.

@byeuji, it could be related depending on if you experience this issue with other apps. This sounds like it might be an issue on your end. We've found that for some people, their computers dispatch media key events properly, avoiding any issues, while other people have issues. It would be hard to replicate your exact issue and find out the cause since the media key issue is rather unpredictable.

@MarshallOfSound, is there any way we could get a fresh instance of Windows to test this on? It would be optimal to test this issue on a Surface device since that is the closest thing there is to a reference Windows machine.

@Kytech I have Windows VM's which I use for lots of my testing to avoid my personal setup conflicting with the results. I would recommend anyone who wants to take this one up does the same 馃憤.

That said we also need it to work on personal setups as well so in an ideal world we would test on everything 馃槅

Also happy to dish out a bit of A/B testing to see if anyone reports any issues with any changes we make

@MarshallOfSound, If I get some time in the next little while, I'll have to spin up some VM's on my local machine and do some tests. I do have one code change that people can test, but I'll keep seeing if I can hammer out any other possible solutions while I'm at it. 馃榾 The one code change I'm using personally is currently a release on the fork I've made as I've been working with this issue.

If anyone wants to do a test with the code change I've made to see if it solves their issue with the duplicating media keys, the download is available here. @Aetheros, that change might be of interest to you. I will publish any testing builds I develop as pre-releases on my fork as of right now. @MarshallOfSound, I think some A/B testing is probably going to be our best bet.

I've noticed that utilities like Microsoft Keyboard and Mouse Center, or the equivalent Logitech software, can affect the way media keys are handled. I can't remember the specifics, but I think I uninstalled the MS software a long time ago as GPDMP wasn't responding to media keys. It works now, but I have the W10 Media Service disabled due to the double-skip issue.

Have the same bug on my Win 10 :(
Would be amazing if you'll fix that ;)

Hey there, I understand where the issue looks to be coming from. I suppose I'm a little confused as to the inability to disable the global key response, but I have a suspicion this is more on Google's side than yours? Electron seems keen to take any global input and pass it to the application to see if it responds. Is that correct in my understanding? Kinda sucky on Google's part if so.

@rinyre it doesn't have much to do with Google Play itself, more just the GPMDP application. Google Play Music does catch media key events when being run in chrome. Electron doesn't forward a key event to the loaded page if the key combination is registered by the electron program. Electron may not forward any key events by default. GPMDP registers the media keys to trigger events in the GPMDP program which then triggers the media events on Google Play Music. I might try working with the default media key behavior of electron to see what I find. Thanks for the observation about Electron.

@MarshallOfSound would it be best to shift focus for OS media integrations to MarshallOfSound/electron-media-service? It seems like our best option is to rewrite the OS media integrations to use this new module once it is ready, which looks to have the integrations built from the ground up, potentially allowing us to avoid the issues we are currently having.

I wanted to update on this issue:

Over the past few weeks, I've allowed my PC to boot fully (from an off-state) and waited a few minutes before opening GPMDP, and while following that procedure, the media keys always work.

I suspect that might mean something like a particular service isn't running yet when I've previously opened GPMDP earlier during startup or something. But when GPMDP is literally the last application to load during boot, the keys always attach properly.

I hope this helps other users, and/or maybe helps indicate the source of the issue (and a possible resolution).

Thanks again!

@byeuji I tried this (after installing Win update and rebooting, not cold-boot) and it did seem to work. However, after I opened a few more programs (Firefox, Outlook, MATLAB) and started using my PC and when I tried to skip again it skipped two songs once more.

@Kytech Your fix works perfectly for me, thank you so much!
I manually patched my installed 4.3.0 version and now it works like a charm.

@Hazerdous @Kytech I don't really have time to go chasing patches 馃槅 If someone has a fix it would be good to submit as a PR here so I can review and potentially merge to get everyone on the right track.

@Kytech Sorry man, must have missed your ping, the long term goal is to move our media integration to that module but this fix shouldn't be dependent on that move. I'm just finishing up exams now so I'm gonna have more time to look at GPMDP stuff again 馃憤

@Kytech your build works fantastically, you should definitely push the changes to the main repo here (Unless @MarshallOfSound has already done so, but I'm not sure) for the next version. It's been an issue that's plagued me since it was implemented because I can't just use the keys on my keyboard for only this one application, and I tend to forget that since it works with literally everything else (FB2K, VLC, WMP, etc).

@Kytech Your build is working PERFECTLY for me as well. Thank you for doing this.

@Kytech I tried out your build and it seemed to work perfectly fine on first run. Keyboard media buttons worked fine with the windows 10 overlay! However, when I opened program again, the media buttons stopped working. Only way to get them working again was by disabling "windows 10 system media service". I tried restarting PC and re-downloading the build, but I couldn't get the media overlay working again.
Not sure how helpful this is, but I thought I should post it here. Thanks for all of the work everyone is putting into this app!

@MarshallOfSound regarding the status/help-wanted label, looks to me like we could fix the double skipping by debouncing the next/prev events that are generated by the Win10 Media Service. The Emitter class already lets us pass details with events. You can assign this to me and I'll look deeper into fixing it when I have time in the next few weeks.

Really hope this is fixed soon. Doesn't make sense to use a "desktop version" if it can't use desktop player features reliably.

Alternatively, for now, we could add a setting to ignore play/pause pushes in the app, instead of trying to ignore the windows 10 cues.

@MarshallOfSound, Sorry I've been unresponsive for a while. I've been away and unable to work on any of my GitHub projects recently. When I can get back to it, I'll do a bit more testing and then I'll submit a PR so we can get this all fixed!

This issue still seems to be a problem in 4.6.1. @Kytech have you had a chance to get around to that testing yet?

@scytail, the most testing I have done was basically with those who tested the build I posted above in a previous comment on this issue, in addition to my regular use of the fix. Most everyone reported not having issues, except maybe one person who responded. I haven't updated this fix for the latest build though, so I really just need to update the fix, look into the one issue, and submit a pull request so then we can just have this fixed. Unfortunately, I don't even have a PC to work with right now, but I will be able to get back to this later this month.

Any news on this? It's definitely still an issue and makes using the program at work a huge pain. If I can't press pause and have it pause then the program is basically useless when the website actually does it.

@portaljacker I've been meaning to update my patch for the newer versions of GPMDP before I send in a poll request. I've been pretty busy with my thesis, so that's taken some time away from me. I should be able to grab a free moment to take care of this sometime within the week.

@Kytech Hope your thesis is going well! :)

Thanks @IndefiniteBen. My thesis went really well. Glad to have that taken care of now! I'm just about to submit a PR to take care of this issue. I will also be taking a look at the play/pause behavior being broken, as mentioned in #3598. That is a separate issue that is related, but is caused by something else. That'll be my next project with GPMDP. If this PR is approved, it should close up this issue.

@Kytech Any update on this? I see you posted your PR version to AppVeyor in this comment on #3598 and the PR is waiting for review for approval for merging. I see however that you're now suggesting a different fix using an updated Windows API in your PR and #2253?
Do you also have a working build of that version or is it better to wait for the PR to be merged?

@IndefiniteBen I do have a working build and it doesn't look like we need to use a different API as it seems to function just fine with my latest fix. I just published it as a release on my branch. You can check it out here. In fact, it looks like the way GPMDP calls into the system media overlay is using the winrt node bindings that Microsoft themselves provided for use with Node/Electron.

I don't currently have access to my PC on which I most often encountered this issue and this PC only has a play/pause button, but the play/pause button works flawlessly now (even while casting).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EzraLopez picture EzraLopez  路  4Comments

amgrider picture amgrider  路  3Comments

greghesp picture greghesp  路  3Comments

St0rmwindX picture St0rmwindX  路  3Comments

kfk2312 picture kfk2312  路  3Comments