mpc-hc(Build for SrtEdit 6.0)扩展源代码 | 首頁 上一頁 下一頁

本着开源的精神，将 SrtEdit 2012 (V6.3)所需 mpc-hc Build for SrtEdit 6.0 所作扩充源代码公布如下： MPC-HC 软件包扩展代码 说明：对 mpc-hc 源代码未作任何删减或功能的改动，只增加了少量 SrtEdit 2012 (V6.3)所需功能的代码。 一、程序修改 １、在 \mpc-hc\src\apps\mplayerc\Resource.h 中增加如下定义

//ywg for SrtEdit

#define ID_PLAY_GOTOEX 993

#define ID_PLAY_STATE 994

#define ID_MEDIA_INFO 995

#define WM_SEND_PLAYSTATE 8000

#define WM_SEND_MEDIAINFO 8001

２、在 \mpc-hc\src\apps\mplayerc\MainFrm.h 中 public: 段中增加

//by ywg, for SrtEdit

afx_msg void OnPlayGotoEx();

afx_msg void OnGetPlayState();

afx_msg void OnGetMediaInfo();

３、在 \mpc-hc\src\apps\mplayerc\MainFrm.cpp 中 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 段中增加

//ywg for SrtEdit

ON_COMMAND(ID_PLAY_GOTOEX, OnPlayGotoEx)

ON_COMMAND(ID_PLAY_STATE, OnGetPlayState)

ON_COMMAND(ID_MEDIA_INFO, OnGetMediaInfo)

及对应的函数实体：

//ywg for SrtEdit 跳转至 lParam 毫秒处播放

void CMainFrame::OnPlayGotoEx()

{

SeekTo(10000i64 * CWnd::GetCurrentMessage()->lParam);

}

//ywg for SrtEdit 获取播放状态（0：停止、1：暂停、2：播放）和当前播放时间（毫秒）

void CMainFrame::OnGetPlayState()

{

::SendMessageW((HWND)CWnd::GetCurrentMessage()->lParam, WM_SEND_PLAYSTATE, GetMediaState(), m_wndSeekBar.GetPosReal()/10000);

}

//ywg for SrtEdit 获取当前播放媒体的总时间长度及帧率

void CMainFrame::OnGetMediaInfo()

{

int h;

h = CWnd::GetCurrentMessage()->lParam;

__int64 start, stop;

m_wndSeekBar.GetRange(start, stop);

REFTIME atpf = 0;

if (FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0) {

atpf = 0;

BeginEnumFilters(pGB, pEF, pBF) {

if (atpf > 0) {

break;

}

BeginEnumPins(pBF, pEP, pPin) {

if (atpf > 0) {

break;

}

AM_MEDIA_TYPE mt;

pPin->ConnectionMediaType(&mt);

if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {

atpf = (REFTIME)((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;

} else if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {

atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;

}

}

EndEnumPins;

}

EndEnumFilters;

}

::SendMessageW((HWND)h, WM_SEND_MEDIAINFO, stop / 10000, 1000 / atpf);

}

二、版本号修改

1、在\mpc-hc\include\Version.h 中#define MPC_VERSION_STR 行加上- Build for SrtEdit 6.0"（必须，为 SrtEdit 判断用）。即：

#define MPC_VERSION_STR MAKE_STR(MPC_VERSION_MAJOR) ", " MAKE_STR(MPC_VERSION_MINOR) ", " MAKE_STR(MPC_VERSION_PATCH) ", " MAKE_STR(MPC_VERSION_REV) " - Build for SrtEdit 6.0"

２、在\mpc-hc\src\apps\mplayerc\mplayerc.rc 及各语言版本的 mplayerc.xx.rc 中加 Build for SrtEdit 6.0（不是必须，在关于…中显示）

LTEXT "Media Player Classic - Home Cinema (Build for SrtEdit 6.0)",IDC_STATIC1,30,5,195,8,SS_NOPREFIX