Yep. Writing myself a little plug-in to make my Remote Wonder work when playing DVDs with Media Player Classic.
MPC is OLE compliant, so you can send it commands like
PostMessage( hMediaPlayerClassic, WM_COMMAND, ID_NAVIGATE_ROOTMENU );
The standard VCR/DVD fast-forward/fast-reverse commands are possible by repeatedly sending one of the seek messages you see below. I’ve reserved holding down the remote control button for ID_PLAY_SEEKxWARDSMALL. So one button press to seek medium speed, two button presses to seek fast, and hold to seek slow.
Without further ado
procedure seek_spam( hWin: HWND; msg: integer; dwData: DWORD; r_esult: LRESULT ); stdcall; // function // Repeatedly trigger the mpc Seek command at exactly the speed that mpc // can respond to its message queue without locking the plug-in's // process. // // Consider: // - No system TIMER object resources are consumed. // - MPC's message queue will not be overflowed. // - The remote control buttons are instantly responsive to the user's // input. The user will not have to wait for backlogged key events to // exhaust themselves before acting on new commands. // // Win32 API SendMessageCallback() returns immediately like PostMessage(), // yet still informs the poster that the target has read the message by // means of a callback. To make life interesting, the callback function // is the sending function: *this* function. Because of the non-blocking // nature of the call, this doesn't cause a call-stack overload. Also, // since the system won't call two different functions in the same thread // at the same time, there is no need for a semaphore or other monitor on // the exit variable (seek_speed). Neat, huh? // // What that means is that an infinite loop is possible if the proper // exit conditions (which are external to this function) are removed!!! // // Exit conditions are: // 1. HandleKey().post() is called // 2. seek_speed is one of 2 or -2 when entering the RMCTRL_FF/RW // switch below in the HandleKey() function body. // // arguments // hWin Must be the handle to the mpc window (hMediaPlayerClassic). // ... All other arguments are ignored. // begin case seek_speed of -2: SendMessageCallback( hWin, WM_COMMAND, ID_PLAY_SEEKBACKWARDLARGE, 0, @seek_spam, 0 ); -1: SendMessageCallback( hWin, WM_COMMAND, ID_PLAY_SEEKBACKWARDMED, 0, @seek_spam, 0 ); 0: ; 1: SendMessageCallback( hWin, WM_COMMAND, ID_PLAY_SEEKFORWARDMED, 0, @seek_spam, 0 ); 2: SendMessageCallback( hWin, WM_COMMAND, ID_PLAY_SEEKFORWARDLARGE, 0, @seek_spam, 0 ) end end;
If you understand why this is so cool, then you’re a super-geek. Honorary pocket protector to you!
If enough people actually care and want to know why this is cool, I’ll tell you later…