在Media Player Classic中,我找到了一种以编程方式跳转到视频/音频中某个点的方法,可以避开Go To...
框。
跳转距离可在“选项”→“调整”中找到,
和HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings
(JumpDistL
/JumpDistM
/JumpDistS
)。
我要做的是在Media Player Classic的地址空间中找到跳转距离,并设置较大跳转距离的值,例如
如果将其应用于耗时,您将获得所需的时间。
然后,我发送带有参数WM_COMMAND
/903
的904
消息(全部通过AutoHotkey。我通过检索/解析Edit控件的内容来获得耗时。)
因为跳跃是相对于当前点的,所以它是不精确的,
并在正确时间的一秒内到达,但没有到达
每次都在完全相同的位置。
有没有更直接的方法可以做到这一点,如果没有,
任何Media Player Classic用户/程序员
考虑在论坛上进行讨论,引入新的WM_COMMAND
消息
允许跳转到点(以毫秒为单位),
或检索列出的数值here
(state
,position
,duration
,volumelevel
,muted
,playbackrate
,reloadtime
)。
(发现here的方法太慢,无法准确获取时间,并且需要设置特殊选项)。
最佳答案
多亏来自wOxxOm的消息,在问题下方,
我已经能够创建此AutoHotkey脚本,
解决了我原来的问题:
以编程方式在Media Player Classic中设置耗时,
直接使用,无需使用Go To...
框。
它还解决了检索问题
有关视频的信息。
热键是:
-Ctrl + Q启动MPC API,
-Ctrl + W检索信息,
-跳到视频途中的数字键。
;==================================================
^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 , ©DATASTRUCT,, % "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
;==================================================
有用的链接:
通过SendMessage发送字符串-寻求帮助-AutoHotkey Community
https://autohotkey.com/board/topic/98334-sending-strings-via-sendmessage/
Media Player Classic-Homecinema MPC远程API(通过WM_COPYDATA)-AutoIt示例脚本-AutoIt论坛
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 - 媒体播放器经典-以编程方式跳转到视频/音频指向,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41310778/