When a video starts on Cobalt 19, is there a callback that will alert me when video starts? - cobalt

I need to handle the Play/Pause remote button which is sending the same code, I am able to toggle and send Play or Pause based on the previous key press, but I am trying to reset the toggle when video starts. For example, if video is paused, then the remote skips to the next track, the toggle is still in pause mode which would require the user to press play twice to get the next video to pause.
The source code is vast and I have been blindly searching for strings with no luck.

If you have only one physical key on a remote, send a kSbKeyMediaPlayPause key instead of trying to guess the state of a web app.

Related

Win32 - How do I catch key event in background, without using global key hook or RegisterHotKey?

I made a program that takes a screenshot of a game window when a specific key is pressed. I am using RegisterHotKey(). It works well, but there is a problem: when the game window is on focus, my program can't receive that key event. To take a screenshot, I have to click the desktop to move the focus to desktop, then press that key. Only in that way can my program receive the key event and take a screenshot. (the game itself provides an in-game camera to take screenshots, but the camera can't take screenshots of UI, inventory, etc. That's why I made this program.)
It's a easy fix to use global key hook, but if I use global key hook, my program will be prone to be identified as a malware (that steals password, for example.) by anti-malware softwares, meaning that I can't share it with other players. (After all, for players that are not good at computer, it is tiring to convince Windows Defender that my program is not malware.)
Is there any idea to catch the key event, but won't make my program identified as a malware?
You can set up a global key monitor by using Raw Input. To do so you need to set the RIDEV_INPUTSINK flag in the RAWINPUTDEVICE structure passed into the RegisterRawInputDevices call.

Browser audio control

If you use firefox (and I assume it works similarily with Chrome/Edge) or Spotify, and you press audio play/pause button, it pauses video/music you are listening to. When my headphones start running out of battery they pause audio for a moment, tell me battery is about to run out, and resume playing. Ergo, I assume there is a way to send "pause music" message, or sth similar.
So my question is: If I have an app (in this case unity game), is there a way in which I can send similar "pause" message to browsers/spotify?

Reliably pause all playing media on Windows

I am setting up a plugin for KDE Connect where I pause any playing media as and when I get a call on my phone. For the Windows build of this plugin, I am currently using VK_MEDIA_PLAY_PAUSE. Is there some instruction(s) I can use to simply PAUSE or simply PLAY the media? That is, not a toggle, instruction(s) with "only one" of the two behaviours?
IF not, is there some other way I can reliably determine if there is any media playing on my system?
I have read Media Play/Pause Simulation . but a toggle is not reliable in my use case.
WM_APPCOMMAND has APPCOMMAND_MEDIA_PAUSE. Send it directly to a player if you know its HWND or send it to yourself and let DefWindowProc turn it into a shell hook event.

jPlayer play event is not firing when audio start playing automatically

I got a problem with jPlayer.
When the page loaded, the player plays automatically but it doesn't trigger "play" event.
Only when I click on pause button and click on play button again, the event is triggered.
Is that a bug of jPlayer?
hard to say since you don't mention which browser you are experiencing this in but my experience is that it is safer to rely on the 'playing' event rather than the 'play' event. Ideally the 'play' event is to be fired as soon as you call jPlayer('play') and 'playing' then is fired once the actual playback starts (i.e. after initial buffering etc). What I've seen this works fine in Safari but does not work in Chrome, in Chrome the two events are both fired when content starts to play.

How to determine which player it will start by sending a Virtual-Key VK_LAUNCH_MEDIA_SELECT

Under Win2K(or later), by sending a Virtual-Key VK_LAUNCH_MEDIA_SELECT, can start a player.
If more than one player software installed, how to determine which one it will start?
A sample VBS code:
Wscript.CreateObject("Wscript.Shell").Sendkeys chr(&h88b5)
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
http://msdn.microsoft.com/zh-cn/library/dd375731
VK_LAUNCH_MEDIA_SELECT
0xB5
Select Media key
VK_LAUNCH_MEDIA_SELECT is actually received by the system and translated into a WM_APPCOMMAND with lParam as APPCOMMAND_LAUNCH_MEDIA_SELECT. So theoretically, any program implementing a handler for this could be launched. This page (albeit old) lists default applications which listen for WM_APPCOMMAND:
Internet Explorer
Windows Help
DVD Player
CD Player
Media Player
Volume Control system tray applet
Obviously, only a few of those are actually applicable for APPCOMMAND_LAUNCH_MEDIA_SELECT.
However, I don't know how the translation mechanism actually works. It appears not every application will receive the translated WM_APPCOMMAND message. On my keyboard, I tried pressing the button which sends VK_VOLUME_UP. The volume goes up as expected because it is handled by the volume control system tray applet. However, I opened an instance of notepad.exe and monitored its messages with Spy++. It did not receive any message even when it was in the foreground. Curiously, VK_MEDIA_PLAY_PAUSE is received through WM_APPCOMMAND if the play/pause button is pressed as long as notepad.exe had the focus. I would test with VK_LAUNCH_MEDIA_SELECT, but I'm not actually sure what button that corresponds to (or whether my keyboard has it).
Thanks, for Mike Kwan's reply.
Through testing a lot of settings a program associated with a variety of audio files.
Finalized, this will depend on the CDA (CD Audio) files associated with which program.
If you set the default association for the CDA (CD Audio) files to Notepad or Paint or any other program, it can still send the same virtual key to open the corresponding program.
The foreground window can do whatever it wants in response to the WM_APPCOMMAND message, if it does not handle the message then shell hooks (HSHELL_APPCOMMAND) gets to handle it, if no hooks handle the message then Windows checks the AppKey key in the registry. (You can use Process Monitor to find the number for a specific key-press)

Resources