getmusicbee.com

MusicBee & Add-Ons => Customizations => Plugins => Topic started by: Steven on March 09, 2017, 06:54:28 PM

Title: Windows 10 Media Control Overlay
Post by: Steven on March 09, 2017, 06:54:28 PM
This plugin (probably!) enables MusicBee to interact with the Windows 10 Media Control overlay.
(http://getmusicbee.com/images/forum/MediaControlOverlay.jpg)

I did this plugin as a "proof of concept" to see if a MusicBee plugin could make use of the new Windows 10 API.
Although it appears to be working, I cant actually confirm because for some reason the overlay wont show on my machine at all (even for other applications that are known to support the media control overlay).
So I am posting this here in case it does work and is useful to someone. Also if a developer wants to make any tweaks so it does work properly the source code is included

Installation:
https://getmusicbee.com/download/plugins/mb_MediaControl.zip
unzip and copy into the MusicBee/Plugins folder

Source Code:
http://www.mediafire.com/file/qya3vl38guelumc/MediaControlSource.zip
Title: Re: Windows 10 Media Control Overlay
Post by: Slj762 on March 11, 2017, 04:44:07 PM
Works great for me.

Thanks!


(https://s30.postimg.org/up75zrvf5/Screenshot_2017_03_11_16_41_07.png)
Title: Re: Windows 10 Media Control Overlay
Post by: Steven on March 11, 2017, 05:06:30 PM
thanks for confirming
Title: Re: Windows 10 Media Control Overlay
Post by: AvikB on March 12, 2017, 09:17:16 AM
thanks. working fine on my machine.
Title: Re: Windows 10 Media Control Overlay
Post by: soundweirdo on March 12, 2017, 08:13:12 PM
It's working! Excellent job!
Title: Re: Windows 10 Media Control Overlay
Post by: boroda on March 23, 2017, 06:26:27 AM
could somebody explain what 'media control overlay' is?
Title: Re: Windows 10 Media Control Overlay
Post by: Bee-liever on March 23, 2017, 01:19:40 PM
'media control overlay' is an OSD (on-screen display) that was introduced in Windows 10.
If you use a media keyboard with your desktop or have separate media keys on your laptop, when you change volume, skip tracks, etc, a pop-up appears on screen showing the volume level and media playing info.
Title: Re: Windows 10 Media Control Overlay
Post by: boroda on March 24, 2017, 01:57:57 PM
thanks
Title: Re: Windows 10 Media Control Overlay
Post by: brainvision on April 01, 2017, 01:10:45 PM
great, thanks!
Title: Re: Windows 10 Media Control Overlay
Post by: rblanca on April 09, 2017, 11:42:26 PM
Working great!. Thanks Steven!
Title: Re: Windows 10 Media Control Overlay
Post by: GreenyRepublic on May 05, 2017, 01:00:38 PM
Fantastic work Steven, thank you for the plugin!

The OSD seems to work fine when I use my laptop's volume keys, though not when I use the ones for play/pause or rewind/fastforward. I'm using an Alienware 13 R2 if anybody else here happens to be and has gotten it working.
Title: Re: Windows 10 Media Control Overlay
Post by: mrshowoff15 on May 08, 2017, 01:16:45 PM
Working great, although it's not showing playing song name or title all it's showing is 'Musicbee.exe'
I'm running windows 10 Pro 64bit.
is there any workaround ?
(http://i.imgur.com/A6OIDdV.png)

Anyway, Thanks alot for this great plugin.
Title: Re: Windows 10 Media Control Overlay
Post by: phred on May 08, 2017, 01:46:26 PM
What version of MB are you using?
Are your tracks tagged properly?
Title: Re: Windows 10 Media Control Overlay
Post by: mrshowoff15 on May 09, 2017, 07:48:20 AM
What version of MB are you using?
Are your tracks tagged properly?
tracks are properly tagged.
It was windows build problem. I was using old build, upgraded to new windows 10 build, it's fixed now.
Title: Re: Windows 10 Media Control Overlay
Post by: Nokiaman on May 11, 2017, 04:26:27 PM
Only shows up if I use the Volume +/- keys. Not sure if that's normal or not.
Title: Re: Windows 10 Media Control Overlay
Post by: yin on May 14, 2017, 02:30:51 PM
Same here, doesn't show when changing songs but shows up if I change volume...
Title: Re: Windows 10 Media Control Overlay
Post by: Alvi_Newcastle on June 12, 2017, 04:33:14 PM
No work here. How did to install this plugin?
Title: Re: Windows 10 Media Control Overlay
Post by: boroda on June 13, 2017, 10:29:51 AM
No work here. How did to install this plugin?
just close mb and unzip archive content to 'plugins' folder inside mb application folder.
Title: Re: Windows 10 Media Control Overlay
Post by: vaso65 on August 17, 2017, 08:43:10 AM
It works for me.

Windows 10 1703 (build 15063.540) x64

Thanks
Title: Re: Windows 10 Media Control Overlay
Post by: Kristof09 on November 05, 2017, 06:26:35 PM
It only works for me when I use the volume +/- buttons but not when I use the play/pause or the next/previous tracks buttons. Any solutions for this?
Title: Re: Windows 10 Media Control Overlay
Post by: Nokiaman on January 13, 2018, 09:44:26 AM
There's another weirdness. MB gets duplicated with this plugin in Volume Mixer. Second one never has any sound.
(https://i.imgur.com/W4kOvkH.png)

3.1.6585
W10 1709
Title: Re: Windows 10 Media Control Overlay
Post by: iamambuser on January 13, 2018, 08:19:33 PM
There's another weirdness. MB gets duplicated with this plugin in Volume Mixer. Second one never has any sound.
(https://i.imgur.com/W4kOvkH.png)

3.1.6585
W10 1709

I get the same. Running MB 3.1.6585 Win10 1709. IIRC it's been like that for awhile. I don't know if I first saw it back in MB 3.0.x or in 3.1.x but its been like that for awhile now.
Title: Re: Windows 10 Media Control Overlay
Post by: moment on March 06, 2018, 02:52:48 AM
Win 8.1 has same layout box for music playing. Could it be possible to make this plugging also for Win 8.1?
Title: Re: Windows 10 Media Control Overlay
Post by: TheKidKidnapper on April 09, 2018, 09:09:34 AM
Latest Windows 10 here and it only shows up when adjusting the volume  :-\
Title: Re: Windows 10 Media Control Overlay
Post by: Alumni on April 19, 2018, 03:49:22 PM
Latest Windows 10 here and it only shows up when adjusting the volume  :-\

Same here, I tried playing around with my keyboard firmware but I can't seem to get the overlay to appear with the play/pause and prev/next keys.
Title: Re: Windows 10 Media Control Overlay
Post by: frankuaku on May 21, 2018, 08:54:22 AM
It was working flawlessly since installation, but it started to going nuts some weeks ago (it didn't display any album art more) and yesterday started to appear only on volume change. Tried to reinstall some minutes ago, but same behaviour. I noticed also the "duplicate" in Audio Mixer.
Title: Re: Windows 10 Media Control Overlay
Post by: quinaeus on July 04, 2018, 11:46:15 AM
very useful, thank you selfless work!
Title: Re: Windows 10 Media Control Overlay
Post by: gmakor on December 17, 2018, 12:34:14 PM
Works fine for me! Thanks Steven!
Title: Re: Windows 10 Media Control Overlay
Post by: bammy on February 12, 2019, 01:08:59 AM
Is it just me or does it only display the track information when changing volume via media keys?

I'm on Windows 10 v1803 (build 17134.523).
Title: Re: Windows 10 Media Control Overlay
Post by: DipperDolphin on April 06, 2019, 01:46:30 PM
Looks good! Is it still in active development?

Thanks :D

---

Edit: Does not work :/
Title: Re: Windows 10 Media Control Overlay
Post by: DZombie on June 23, 2019, 06:54:48 AM
This was written through Google Translate.

First of all thank such an excellent plugin.
I want to mention that it works so far in Windows 10 (1903).

(https://i.imgur.com/ICL5bVq.png)

As you can notice by having their respective tags shows that information as if it were the native player of Windows.

(https://i.imgur.com/BFGm1yb.png)

Likewise in the blocking screen shows the above.

(https://i.imgur.com/11Kag0w.png)

Finally for those who have problems not visualize the plugin to be the first time they use it, I commented that
Quote
only the file not the folder
, only the file
Quote
should be copied into the plugins folder
.
Finally thank you again for your work.
Title: Re: Windows 10 Media Control Overlay
Post by: allavaz on June 24, 2019, 01:46:01 AM
I tried grabbing the code to try to make it show up when using play/pause and prev/next keys but when I opened the project in VS2019 all I got were errors (without even touching the code):

(https://i.imgur.com/HARE5uK.png)

But at least I tried :p maybe the source code is outdated?
Title: Re: Windows 10 Media Control Overlay
Post by: k0to on July 10, 2019, 06:20:55 AM
Does anyone else get a double input play/pause now when using with the overlay as mentioned in this post: https://getmusicbee.com/forum/index.php?PHPSESSID=10eeb080362fa5031efa27a49149b691&topic=29056.0
Title: Re: Windows 10 Media Control Overlay
Post by: Janker on July 11, 2019, 09:15:45 PM
Does anyone else get a double input play/pause now when using with the overlay as mentioned in this post: https://getmusicbee.com/forum/index.php?PHPSESSID=10eeb080362fa5031efa27a49149b691&topic=29056.0

Everytime I try to use the addon at the moment . I,m guessing its something on Microsoft's end at this pont as I've tried it on both the Windows store and website (3.3) versions with no fix.
Title: Re: Windows 10 Media Control Overlay
Post by: Havokdan on July 12, 2019, 09:47:48 AM
This happens to me only after I see some media in the browser, it seems that somehow the play / pause button is affected, I do not know if it's the same case, but I found it important to report here.
Title: Re: Windows 10 Media Control Overlay
Post by: k0to on July 12, 2019, 07:04:37 PM
I've disabled the media buttons on Chrome by using flags, still does the double input thing.
Title: Re: Windows 10 Media Control Overlay
Post by: stardepp on July 12, 2019, 09:25:36 PM
Code
chrome://flags/#hardware-media-key-handling
Title: Re: Windows 10 Media Control Overlay
Post by: waste on September 06, 2019, 05:22:36 AM
Unfortunately this plugin has a major bug, when pressing media keys on the keyboard the presses register twice. Once by the Media Control Overlay/Plugin and once by MusicBee. This causes track skipping and breaks the pause and play functionality as the commands are doubled.

I have tried to fix this by editing the code of the plugin but its difficult without extending the plugin API or something along those lines with information from MusicBee about when it intercepts the keyboard press of the media keys in or order to prevent the plugin from repeating the action that was already handled by MusicBee if that makes sense. It would be great if the API told the plugin if a song change/pause/play was triggered by a media key or something else.

Another option would be to allow the plugin itself to handle the media keys and removing them from MusicBee's hotkeys but that is honestly beyond my coding abilities.
Title: Re: Windows 10 Media Control Overlay
Post by: Steven on September 06, 2019, 07:07:42 AM
Unfortunately this plugin has a major bug, when pressing media keys on the keyboard the presses register twice. Once by the Media Control Overlay/Plugin and once by MusicBee. This causes track skipping and breaks the pause and play functionality as the commands are doubled.
https://getmusicbee.com/forum/index.php?topic=29056.msg164467#msg164467
Title: Re: Windows 10 Media Control Overlay
Post by: kid on December 27, 2019, 11:53:08 PM
Just wanted to report in,
Plugin works like a charm, does exactly as it should.
When someone wants to use it in combination with universal media keys, be sure to disable the global hotkeys in the MB settings to prevent the double registering of key presses like mentioned in the other topic by Steven.

However for me it is not convenient to use.
- The media control overlay only "turns on" when media is playing.
    This means that there is no way to start playback with a media key after launching MB.
- Media control overlay gets hijacked by all sorts of other "media" players, meaning losing control over Musicbee.
- Microsoft seems to change the behavior occasionally with (feature) updates, might cause the feature to break in the future.

One peculiar thing I noticed;
the universal media keys on my K850 don't work with MB by default. The plugin fixes that, since MB then responds to the media control overlay from the OS, rather than a keyboard input. This seems to be a shitty "Logitech Options" media keys implementation (don't get me started on setpoint or intellitype "handling" of standard functions). However my M720 media gestures control playback just fine through the same (crappy) piece of software.

My Onkyo remote works fine through WinLIRC/frIRR! both without plugin and with plugin and hotkeys disabled, which is expected behavior. (I am 100% this sends out "normal" universal media control keystrokes)

Thanks Steven!
Title: Re: Windows 10 Media Control Overlay
Post by: alexdo on April 20, 2020, 09:51:49 PM
The whole problem is because of the media control "feature" that if you press a keyboard media key, the media control also simulates a click on its buttons. And the plugin defines the appropriate action for the buttons. So everything is executed two times - one from media control buttons callback and one from music bee global hotkey.

So here is a fixed plugin for everyone who wants to have working media control buttons and working global hotkeys:
http://www.mediafire.com/file/7fdiewd2r3df62i/mb_MediaControl.zip/file

The fix uses a keyboard key press hook that watches for keyboard media key presses and saves the time of the last press. And if last press is less than 1500 milliseconds ago the media control button press is ignored.

For everyone who doesn't trust me, here is the source to see what is done and compile it yourself:
http://www.mediafire.com/file/hfrflurmkonsv8f/MediaControlSource.zip/file
Title: Re: Windows 10 Media Control Overlay
Post by: MissPat on May 05, 2020, 05:23:36 AM
Hello all,

Question: is it just me or did the plugin stop working with Musicbee 3.3.7367 ?

I have installed it in the "plugins" folder as instructed but only the vanilla control overlay ever shows up when a playlist switches to a new track.

My MusicBee folder is on the "D" drive, could that be a problem?

Please let me know - would love to give the plugin a try.
Title: Re: Windows 10 Media Control Overlay
Post by: phred on May 11, 2020, 08:53:03 PM
I have installed it in the "plugins" folder as instructed but only the vanilla control overlay ever shows up when a playlist switches to a new track.

My MusicBee folder is on the "D" drive, could that be a problem?
If your MB .exe file and installation of the entire application is on your D: drive, then your plugins directory is located under it. That's where this plugin belongs.
Title: Re: Windows 10 Media Control Overlay
Post by: anthony_p on May 15, 2020, 07:52:05 PM
EDIT : Well, I got ignored so ... one last time maybe ?

Anyways, after updating my PC to Windows 10 1903, the overlay is not displaying the currently playing song's artwork. It only does does so occasionally when the the song is played a couple of times on loop.

I have the latest version of Musicbee, and and did try completely uninstalling and reinstalling it to no avail. The problem persists with the Store App. I think it has something to do with Musicbee, as chrome and other players work just fine with the overlay.

I'd really appreciate the help, as I rely a lot on the overlay, and would love to see it as it should be :(

PS. And I did install the latest patch. No change.
Title: Re: Windows 10 Media Control Overlay
Post by: carlosmg2 on November 18, 2020, 03:14:42 PM
The whole problem is because of the media control "feature" that if you press a keyboard media key, the media control also simulates a click on its buttons. And the plugin defines the appropriate action for the buttons. So everything is executed two times - one from media control buttons callback and one from music bee global hotkey.

So here is a fixed plugin for everyone who wants to have working media control buttons and working global hotkeys:
http://www.mediafire.com/file/7fdiewd2r3df62i/mb_MediaControl.zip/file

The fix uses a keyboard key press hook that watches for keyboard media key presses and saves the time of the last press. And if last press is less than 1500 milliseconds ago the media control button press is ignored.

For everyone who doesn't trust me, here is the source to see what is done and compile it yourself:
http://www.mediafire.com/file/hfrflurmkonsv8f/MediaControlSource.zip/file

Thanks a lot!! this solved my issue.  I was getting crazy.
They should update the original plugin.
Title: Re: Windows 10 Media Control Overlay
Post by: Nokiaman on December 16, 2020, 07:45:33 PM
The whole problem is because of the media control "feature" that if you press a keyboard media key, the media control also simulates a click on its buttons. And the plugin defines the appropriate action for the buttons. So everything is executed two times - one from media control buttons callback and one from music bee global hotkey.

So here is a fixed plugin for everyone who wants to have working media control buttons and working global hotkeys:
http://www.mediafire.com/file/7fdiewd2r3df62i/mb_MediaControl.zip/file

The fix uses a keyboard key press hook that watches for keyboard media key presses and saves the time of the last press. And if last press is less than 1500 milliseconds ago the media control button press is ignored.

For everyone who doesn't trust me, here is the source to see what is done and compile it yourself:
http://www.mediafire.com/file/hfrflurmkonsv8f/MediaControlSource.zip/file

Thank you so much!
Title: Media Overlay Lingering
Post by: PlumBlossom on September 21, 2021, 09:30:44 PM
Hello everyone!
I recently reset my laptop and reinstalled Windows and everything related. I downloaded the patched Windows 10 Media Overlay plugin and it works perfectly. The only thing I noticed is that the overlay block thing lingers on the screen for a bit before it fades away. It used to fade away much sooner when I had it before. It's really not too big of a deal because, like I said, the plugin works perfectly but I was wondering if there was a way to adjust it? Thanks!
Title: Re: Windows 10 Media Control Overlay
Post by: literaldehyde on January 31, 2023, 09:42:50 AM
The whole problem is because of the media control "feature" that if you press a keyboard media key, the media control also simulates a click on its buttons. And the plugin defines the appropriate action for the buttons. So everything is executed two times - one from media control buttons callback and one from music bee global hotkey.

So here is a fixed plugin for everyone who wants to have working media control buttons and working global hotkeys:
http://www.mediafire.com/file/7fdiewd2r3df62i/mb_MediaControl.zip/file

The fix uses a keyboard key press hook that watches for keyboard media key presses and saves the time of the last press. And if last press is less than 1500 milliseconds ago the media control button press is ignored.

For everyone who doesn't trust me, here is the source to see what is done and compile it yourself:
http://www.mediafire.com/file/hfrflurmkonsv8f/MediaControlSource.zip/file

I have the bug where the base plugin plays tracks over each other, but this version of the plugin just completely disables media controls for me. Using 3.4.8033.
Title: Re: Windows 10 Media Control Overlay
Post by: phred on January 31, 2023, 01:31:51 PM
Using 3.4.8033.
If you're not using the Store version, try using the latest 3.5 from the first forum topic. If you're on the Store version there's nothing you can do until a new Store version is released.
Title: Re: Windows 10 Media Control Overlay
Post by: literaldehyde on February 13, 2023, 02:50:41 PM
Using 3.4.8033.
If you're not using the Store version, try using the latest 3.5 from the first forum topic. If you're on the Store version there's nothing you can do until a new Store version is released.

I've updated to 3.5 and it hasn't changed anything. But I believe I've fixed the problem for myself.

I forgot to mention that because my laptop doesn't have dedicated media control buttons, I use an AutoHotkey script to rebind Ctrl+Shift+Left to Media_Prev, Ctrl+Shift+Right to Media_Right, and Ctrl+Shift+/ to Media_Play_Pause. I believe these AHK hotkeys send simulated media control presses, but aren't real buttons so alexdo's fix wasn't actually necessary for me. I only thought I needed it because I gave myself the double register bug by having the MusicBee multimedia global hotkeys set to the virtual media control buttons because I must have had the script running when I set them. This caused both MusicBee and Autohotkey to send media control commands simultaneously, instead of MusicBee + keyboard button conflicts other people were having.

I fixed it by changing the MusicBee multimedia global hotkeys to Ctrl+Shift+Left, Right, etc. while the AHK script was disabled. And now after reenabling it everything seems to be working fine including the overlay using the original version of the plugin. Only minor gripe is that as others have reported, audio needs to be played directly through the MusicBee window once after it starts up before the hotkeys begin to register. I noticed the Spotify app doesn't have that problem so I imagine there's a potential fix but who knows? Media Controls do conflict with other media players like Spotify, but that's not a problem for me because I've never needed to have both open at the same time.

Cheers!
Title: Re: Windows 10 Media Control Overlay
Post by: froschfinger on March 24, 2023, 06:46:12 PM
So far, this is working really well with the fixed version for the media keys from here. On Windows 11, this also intends to show the duration and track position a song is at, only it shows its length as 0:00 and as 100% played, no matter at what position the playback actually is, so the duration functionality doesn't seem to work. Did anybody ever solve this?
On top of it, this would be even sweeter if it showed up each time a new track is playing, just like the internal playback toast notification. I guess one can't have it all…
Title: Re: Windows 10 Media Control Overlay
Post by: CharlieJiang on May 15, 2023, 04:49:22 PM
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=SDaFnQ

The 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.
Title: Re: Windows 10 Media Control Overlay
Post by: froschfinger on May 17, 2023, 03:01:41 PM
Hey Charlie,

thanks for your new version. In fact, that was a good tip: Disabling the global media keys. I didn't need to delete them, I just unticked them to be global. That also solved the problem that when another app is having media playback, using the media keys on my keyboard toggled playback, so when one source stopped, the other one started playing (like YouTube and Musicbee). So as it stands, I won't need to recompile your version, so thanks a lot for the bug-fix version! If you at any point will be able to test the plugin with Windows 11, a fix for the progress bar and time display will come in handy. So far I'm happy I'm backing to having an overlay showing what song is playing or paused ;) .
Title: Re: Windows 10 Media Control Overlay
Post by: bcrod on July 01, 2023, 09:19:22 PM
The overlay isn't update anymore when music is changed. Using Win 11 (last update in 01/07/2023)
Title: Re: Windows 10 Media Control Overlay
Post by: bcrod on July 01, 2023, 09:28:55 PM
The overlay isn't update anymore when music is changed. Using Win 11 (last update in 01/07/2023)

Forget it. Just reinstall and work again.
Title: Re: Windows 10 Media Control Overlay
Post by: HenryPDT on January 27, 2024, 03:29:30 AM
I improved on @CharlieJiang by fixing some broken/missing SMTC features such as Shuffle, Repeat and Timeline Info/Control to work with ModernFlyouts and other programs that read those SMTC information. This should work perfectly on Windows 11

DLL and source code can be found on:
https://github.com/HenryPDT/mb_MediaControl (https://github.com/HenryPDT/mb_MediaControl)