I've noticed some minor issues in alexdo's version:
1. I didn't register global media keys in MusicBee, so there's no actually double register issue for me. Therefore, the fix against double registration directly disabled my media keys.
2. The display isn't updated in time. When I click the Next track button in the overlay, the display isn't updated until it appears again.
3. The player and the overlay may get confused and lag if I spam-click the buttons in the overlay.
Therefore, I wrote a small fixed version for these 3 issues. Note that I disabled alexdo's fix for the double register problem, but you may need it! If that's the case, at the Line 29 in the `MediaControl.cs`, replace "0" to "2000", and recompile.
Here's the code and DLL files (I didn't upload this to GitHub because I don't know what's the open-source license):
https://1drv.ms/f/s!AicHZ6DLvCtXgYhCqD050XH_TeJF8Q?e=SDaFnQThe key is to call `SetDisplayValues` and `SetPlayerState` right after any operation is done, and before calling `Player_PlayPause`, check if we really need to do that by calling `Player_GetPlayState` (When the player is paused, and the user issued a Pause command may be due to lag in UI update, you wouldn't want `Player_PlayPause` to be called because it actually starts the playback).
Several things to note:
1. Direct dependency on UWP DLLs is replaced to NuGet package `Microsoft.Windows.SDK.Contracts`, which handles the references to SMTC classes.
2. packages.config migrated to PackageReference.
3. Fody is used to weave global mouse key hook DLL into the final plugin DLL.
4. .NET Framework version is changed to 4.8.
5. The compiler complains that `BackgroundMediaPlayer` is obsolete, but I didn't find a better way to obtain `SystemMediaTransportControls` object in a desktop (non-UWP) app - advice needed!
6. @froschfinger It's certainly doable via `SystemMediaTransportControlsTimelineProperties` in the SMTC feature. However, I'm now using Windows 10 instead of Windows 11, so I don't have the chance to test such a feature, sorry...
It should be easier to compile this codebase than the original version due to the first 3 changes above. Notably, I expect that the compiler won't complain about the missing reference to UWP namespaces.