Media commands Win10
Describe the bug There's a high probability that I'm missing something but after weeks I'm desperate. I cannot get working keys for media commands - VK_MEDIA_PLAY_PAUSE, VK_PLAY, VK_PAUSE. Any help is appreciated. Thanks in advance.
Other commands like VK_VOLUME_UP, VK_VOLUME_DOWN, VK_ESCAPE works fine.
To Reproduce Steps to reproduce the behavior:
- Play media in Kodi, VLC or Chrome web player
- Connect to the MCE controller via Putty
- Type the command VK_VOLUME_UP
- Volume goes up, so connection works
- Type VK_PAUSE
- MCE controller log accepts command
- Media will not pause
Expected behavior Media should pause, nothing happens.
Screenshots
This is the machine where MCE runs after issuing VK_VOLUME_UP, so the Windows recognizes playing media:
After issuing a pause command nothing happens, Windows media control doesn't show up.
Version Information
2023-03-07 04:01:47,986 INFO - MCE Controller v2.3.0.1 - OS: Microsoft Windows NT 10.0.19045.0 on x64 - .NET: 4.0.30319.42000
Snippets from the log
2023-03-07 20:58:57,528 DEBUG - SocketServer BeginReceive
2023-03-07 20:58:57,528 INFO - SocketServer: Received from Client #1 at 192.168.1.11:55823: VK_PAUSE
2023-03-07 20:58:57,529 DEBUG - SocketServer BeginReceive
2023-03-07 20:58:57,546 INFO - SendInputCommand Cmd="VK_PAUSE" Args="" Vk="VK_PAUSE" Shift="False" Ctrl="False" Alt="False" Win="False" (VK_PAUSE) (0x13)
2023-03-07 21:09:54,292 DEBUG - SocketServer BeginReceive
2023-03-07 21:09:54,294 INFO - SocketServer: Received from Client #1 at 192.168.1.11:55823: VK_VOLUME_UP
2023-03-07 21:09:54,294 DEBUG - SocketServer BeginReceive
2023-03-07 21:09:54,311 INFO - SendInputCommand Cmd="VK_VOLUME_UP" Args="" Vk="VK_VOLUME_UP" Shift="False" Ctrl="False" Alt="False" Win="False" (VK_VOLUME_UP) (0xaf)
Desktop (please complete the following information): ThinkPad W530 notebook with closed lid and connected to the projector via HDMI.
Additional context I have tested pausing with VLC Media Player, Kodi, and Chrome playing media.
First, not all apps respond to the VK_MEDIA_xxx keys.
Second, whatever app needs to be in the forground for these VK codes to work (pre-Win7 this was not the case IIRC).
So, create a new command like this:
<setforegroundwindow cmd="mplayer" enabled="true" classname="vlc" appname="vlc" />
Then send:
mplayer
VK_MEDIA_STOP
Note, VLC does not respond to VK_PLAY. You have to send VK_SPACE. You can change VLC's keyboard mapping in it's Preferences dialog.
I could not figure out what appname to use to get Windows' Media Player to go to foreground. I thought it would be Microsoft.Media.Player but I can't get that to work.
This activates Windows Media Player:
VK_LWIN
pause:100
chars:media player
pause:100
enter
however, none of the VK_MEDIA_ keys work. VK_SPACE does toggle play/pause.
VK_LWIN
pause:100
chars:media player
pause:100
enter
pause:250
VK_SPACE
Actually, this works too:
VK_LWIN
pause:100
chars:media player
pause:100
enter
pause:250
VK_MEDIA_PLAY_PAUSE
Thank you for your suggestions. I was assuming that VK_MEDIA_PLAY_PAUSE would emulate the media button press on the keyboard. Thus, the application registered on the OS level, as an active player, will be paused/played.
I'm looking for a solution, which will work for any media sources (Chrome web player, VLC, Netflix app, Kodi...).
The next step would be to test if the actual hardware play/pause button will work and if yes, then emulate it.
Thank you for your suggestions. I was assuming that VK_MEDIA_PLAY_PAUSE would emulate the media button press on the keyboard. Thus, the application registered on the OS level, as an active player, will be paused/played.
I'm looking for a solution, which will work for any media sources (Chrome web player, VLC, Netflix app, Kodi...).
The next step would be to test if the actual hardware play/pause button will work and if yes, then emulate it.
IIRC before Win10, MCEC did emulate VK_MEDIA_PLAY_PAUSE etc correctly. But something in the OS changed that prevented from apps from doing so. I suspect it was some sort of security reason.