Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media commands Win10 #37

Open
matushromada opened this issue Mar 7, 2023 · 5 comments
Open

Media commands Win10 #37

matushromada opened this issue Mar 7, 2023 · 5 comments

Comments

@matushromada
Copy link

matushromada commented Mar 7, 2023

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:

  1. Play media in Kodi, VLC or Chrome web player
  2. Connect to the MCE controller via Putty
  3. Type the command VK_VOLUME_UP
  4. Volume goes up, so connection works
  5. Type VK_PAUSE
  6. MCE controller log accepts command
  7. 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:
Screenshot 2023-03-07 at 21 10 18
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.

@tig
Copy link
Owner

tig commented Mar 8, 2023

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

image

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.

@tig
Copy link
Owner

tig commented Mar 8, 2023

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

@tig
Copy link
Owner

tig commented Mar 8, 2023

Actually, this works too:

VK_LWIN
pause:100
chars:media player
pause:100
enter
pause:250
VK_MEDIA_PLAY_PAUSE

@matushromada
Copy link
Author

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.

@tig
Copy link
Owner

tig commented Mar 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants