媒体播放器经典-以编程方式指向视频/音频 [英] media player classic - jump to point in video/audio programmatically

查看:135
本文介绍了媒体播放器经典-以编程方式指向视频/音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Media Player Classic中,我找到了一种以编程方式跳转到视频/音频中某一点的方法,可以避开Go To...框. 跳转距离可在选项调整中找到, 和HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings (JumpDistL/JumpDistM/JumpDistS).

In Media Player Classic I found a way to jump to a point in a video/audio programmatically, avoiding the Go To... box. The jump distances are available at OptionsTweaks, and HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings (JumpDistL/JumpDistM/JumpDistS).

我要做的是在Media Player Classic的地址空间中找到跳跃距离,并设置较大跳跃距离的值,例如 如果将其应用于经过的时间,您将获得所需的时间.

What I do is find the jump distances in the address space of Media Player Classic, and set the value of the large jump distance such that if you applied it to the elapsed time you would get the desired time.

然后我发送一个带有参数903/904WM_COMMAND消息(全部通过AutoHotkey.我通过检索/解析 Edit 控件的内容来获得经过的时间.)

I then send a WM_COMMAND message with parameter 903/904 (all via AutoHotkey. I get the elapsed time by retrieving/parsing the contents of the Edit control.)

由于相对于当前点相对而言,它是不精确的, 并在正确时间的一秒内到达,但没有到达 每次都在同一点.

Because the jump is relative to the current point, it is imprecise, and arrives within a second of the right time, but doesn't arrive at exactly the same point each time.

是否有更直接的方法来实现这一目标,如果没有, 任何Media Player Classic用户/程序员 考虑在论坛上进行讨论,引入新的WM_COMMAND消息 允许跳转到点(以毫秒为单位), 或检索此处列出的数值 (statepositiondurationvolumelevelmutedplaybackratereloadtime). (在此处找到的方法太慢,无法准确获取时间,并且需要设置特殊选项).

Is there a more direct way of accomplishing this and if not, would any Media Player Classic users/programmers consider discussing on the forum, introducing new WM_COMMAND messages that allow jump to point (in milliseconds), or that retrieve the numerical values listed here (state, position, duration, volumelevel, muted, playbackrate, reloadtime). (The method found here is too slow to get the time accurately, and requires special options be set).

推荐答案

感谢来自wOxxOm的问题下方的消息, 我已经能够创建此AutoHotkey脚本, 解决了我原来的问题: 以编程方式在Media Player Classic中设置经过时间, 直接,而无需使用Go To...框.

Thanks to the message from wOxxOm, below the question, I have been able to create this AutoHotkey script, which solves my original problem: to set the elapsed time in Media Player Classic programmatically, directly, without using the Go To... box.

它也解决了检索问题 有关视频的信息.

It also solves the problem of retrieving information about the video.

热键是:
- Ctrl + Q 启动MPC API,
- Ctrl + W 检索信息,
-跳到视频途中的数字键.

The hotkeys are:
- Ctrl+Q to start the MPC API,
- Ctrl+W to retrieve information,
- the number keys to jump partway 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

;==================================================

有用链接:

通过SendMessage发送字符串-寻求帮助-AutoHotkey社区
https://autohotkey.com/board/topic/98334-sending -strings-via-sendmessage/

Sending Strings Via SendMessage - Ask for Help - 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/

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

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

这篇关于媒体播放器经典-以编程方式指向视频/音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆