Classic media player - transition to a point in video / audio programmatically

In Media Player Classic, I found a way to jump to a point in video / audio programmatically, avoiding Go To... Jump distance is available in Options β†’ Tweaks , and HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings ( JumpDistL / JumpDistM / JumpDistS ).

What I'm doing is finding the transition distances in the address space of Media Player Classic and setting the value of the large transition distance so that if you apply it to the elapsed time, you will get the desired time.

Then I send a WM_COMMAND message with parameter WM_COMMAND (all through AutoHotkey. I get the elapsed time by fetching / parsing the contents of the Edit control.)

Since the jump refers to the current point, this is inaccurate, and comes within a second at the right time, but does not come at exactly the same point every time.

Is there a more direct way to accomplish this, and if not, will there be users / programmers of Media Player Classic Classic think about the discussion on the forum, by introducing new WM_COMMAND messages that allow you to jump to the point (in milliseconds), or that return the numerical values ​​listed here ( state , position , duration , volumelevel , muted , playbackrate , reloadtime ). (The method found here is too slow to determine the exact time and requires special options).

+5
source share
1 answer

Thanks to the post from wOxxOm, below the question, I was able to create this AutoHotkey script that solves my original problem: set the software time in Media Player Classic, directly, without using the Go To... field.

It also solves the problem of retrieving video information.

Hotkeys:
- Ctrl + Q to launch the MPC API,
- Ctrl + W to get information,
- Numeric keys to navigate through the video.

 ;================================================== ^q:: ;start MPC API hWnd := A_ScriptHwnd+0 OnMessage(WM_COPYDATA:=74, "On_WM_COPYDATA") ;64-bit Run, "C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC64\mpc-hc64.exe" /slave %hWnd% ;32-bit ;Run, "C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC\mpc-hc.exe" /slave %hWnd% Return ;================================================== ^w:: ;display information Send(vMPCApiHWnd, 0xA0003004, "") ;CMD_GETCURRENTPOSITION := 0xA0003004 vElapsed := 19990101 vDuration := 19990101 vElapsed += vMPCApiCurrent, S vDuration += vMPCApiDuration, S if (vMPCApiCurrent >= 3600) OR (vMPCApiDuration >= 3600) vFormat := "HH:mm:ss" else vFormat := "mm:ss" FormatTime, vElapsed, %vElapsed%, %vFormat% FormatTime, vDuration, %vDuration%, %vFormat% SplitPath, vMPCApiPath, vName, vDir, vExt, vNameNoExt, vDrive vText = ;continuation section ( title: %vMPCApiTitle% author: %vMPCApiAuthor% description: %vMPCApiDesc% name: %vName% path: %vMPCApiPath% elapsed: %vElapsed% (%vMPCApiCurrent%) duration: %vDuration% (%vMPCApiDuration%) ) MsgBox %vText% Return ;================================================== #IfWinActive, ahk_class MediaPlayerClassicW 0:: ;skip to point 1:: 2:: 3:: 4:: 5:: 6:: 7:: 8:: 9:: vNum := SubStr(A_ThisHotkey, 1-1) vElapsed2 := Round(vMPCApiDuration*(vNum/10)) Send(vMPCApiHWnd, 0xA0002000, "" vElapsed2) ;CMD_SETPOSITION := 0xA0002000 Return #IfWinActive ;================================================== On_WM_COPYDATA(wParam, lParam, msg, hwnd) { global vMPCApiHWnd global vMPCApiTitle global vMPCApiAuthor global vMPCApiDesc global vMPCApiPath global vMPCApiDuration global vMPCApiCurrent dwData := NumGet(lParam+0, 0) cbData := NumGet(lParam+A_PtrSize) lpData := NumGet(lParam + 2*A_PtrSize) lpData := StrGet(lpData) if (dwData = 0x50000000) ;CMD_CONNECT := 0x50000000 { vMPCApiHWnd := lpData WinGetClass, vWinClass, ahk_id %vMPCApiHWnd% if (vWinClass = "MediaPlayerClassicW") MsgBox, , , MPC API on, 3 } if (dwData = 0x50000003) ;CMD_NOWPLAYING := 0x50000003 { StringSplit, lpData, lpData, | vMPCApiTitle := lpData1 vMPCApiAuthor := lpData2 vMPCApiDesc := lpData3 vMPCApiPath := lpData4 vMPCApiDuration := lpData5 } if (dwData = 0x50000007) ;CMD_CURRENTPOSITION := 0x50000007 vMPCApiCurrent := lpData Return true } ;================================================== Send(Hwnd, dwData, lpData) { static WM_COPYDATA := 0x4a VarSetCapacity(COPYDATASTRUCT, 3*A_PtrSize, 0) cbData := (StrLen(lpData) + 1) * (A_IsUnicode ? 2 : 1) NumPut(dwData, COPYDATASTRUCT, 0) NumPut(cbData, COPYDATASTRUCT, A_PtrSize) NumPut(&lpData, COPYDATASTRUCT, 2*A_PtrSize) SendMessage, % WM_COPYDATA, % A_ScriptHwnd , &COPYDATASTRUCT,, % "ahk_id " Hwnd return ErrorLevel == "FAIL" ? false : true } ;================================================== ;USEFUL LINKS ;Sending Strings Via SendMessage - Ask for Help - AutoHotkey Community ;https://autohotkey.com/board/topic/98334-sending-strings-via-sendmessage/ ;Media Player Classic - Homecinema MPC remote API (via WM_COPYDATA) - AutoIt Example Scripts - AutoIt Forums ;https://www.autoitscript.com/forum/topic/85354-media-player-classic-homecinema-mpc-remote-api-via-wm_copydata/ ;mpcapi.h ;https://raw.githubusercontent.com/jeeb/mpc-be/master/src/apps/mplayerc/mpcapi.h ;winapi - media player classic - jump to point in video/audio programmatically - Stack Overflow ;http://stackoverflow.com/questions/41310778/media-player-classic-jump-to-point-in-video-audio-programmatically ;================================================== 

USEFUL LINKS:

Sending Strings via SendMessage - Ask a Question - AutoHotkey Community
https://autohotkey.com/board/topic/98334-sending-strings-via-sendmessage/

Media Player Classic - Remote Homecinema MPC API (via WM_COPYDATA) - AutoIt Scripting Scripts - AutoIt Forums
https://www.autoitscript.com/forum/topic/85354-media-player-classic-homecinema-mpc-remote-api-via-wm_copydata/

mpcapi.h
https://raw.githubusercontent.com/jeeb/mpc-be/master/src/apps/mplayerc/mpcapi.h

+4
source

Source: https://habr.com/ru/post/1261820/


All Articles