首先,我们需要把common.lib添加到VS2005/项目属性/链接器/输入项中,同时把common.dll和common.lib放到项目文件夹中,TCPMP中的COMMON文件夹放到上一层文件夹。
其次,在程序中对插件进行初始化和构建播放器节点的操作。具体如下:
//Context init
Context_Init((tchar_t*)T("TCPMP"),(tchar_t*)T("0.72SRC"),3,(tchar_t*)lpCmdLine,NULL);
//上下文创建
context* p=Context();
//播放模块的初始化
myplayer=NULL;
if(p) myplayer=(player*)(p->Player);
//播放窗口关联
Context_Wnd(g_hWnd);
//错误处理函数设定
p->Error.This=myplayer;
p->Error.Func=DoError;
//视频 音频的类节点
array VOutput;
array AOutput;
NodeEnumClass(&VOutput,VOUT_CLASS);
NodeEnumClass(&AOutput,AOUT_CLASS);
如需要EQ可以如下设定:
//EQ 节点
Eq=NodeEnumObject(NULL,EQUALIZER_ID);
有了播放节点myplayer,我们就可以对播放进行控制相关的操作了。以下列举常用操作;
1.播放和暂停
(myplayer->Get(myplayer,PLAYER_PLAY,&State,sizeof(State))==ERR_NONE)
{
State = !State; myplayer->Set(myplayer,PLAYER_PLAY,&State,sizeof(State));
}
2.停止
myplayer->Set(myplayer,PLAYER_STOP,NULL,0);
f.Num = 0;
f.Den = 1;
myplayer->Set(myplayer,PLAYER_PERCENT,&f,sizeof(f));
3.下曲 上曲
myplayer->Set(myplayer,PLAYER_NEXT,NULL,0); myplayer->Set(myplayer,PLAYER_PREV,NULL,0);
4.静音与否
if (myplayer->Get(myplayer,PLAYER_MUTE,&State,sizeof(State))==ERR_NONE)
{
State = !State;
myplayer->Set(myplayer,PLAYER_MUTE,&State,sizeof(State));
}
5.音量或者和设置 myplayer->Get(myplayer,PLAYER_VOLUME,&vols,sizeof(vols));
myplayer->Set(myplayer,PLAYER_VOLUME,&vols,sizeof(vols));
6.播放模式设置
Int ModeSelY=1,ModeSelN=0;
myplayer->Set(myplayer,PLAYER_REPEAT,&ModeSelY,sizeof(ModeSelY));
myplayer->Set(myplayer,PLAYER_SHUFFLE,&ModeSelN,sizeof(int));
另:
tchar_t sss[128];
myplayer->CommentByName(myplayer,0,PlayerComment(COMMENT_ALBUM),sss,TSIZEOF(sss));
是获得ID3信息的途径。
支持参数如下:
#define COMMENT_TITLE 0x110
#define COMMENT_ARTIST 0x111
#define COMMENT_ALBUM 0x112
#define COMMENT_LANGUAGE 0x113
#define COMMENT_GENRE 0x114
#define COMMENT_AUTHOR 0x115
#define COMMENT_COPYRIGHT 0x116
#define COMMENT_PRIORITY 0x117
#define COMMENT_COMMENT 0x118
#define COMMENT_TRACK 0x119
#define COMMENT_YEAR 0x11A
#define COMMENT_COVER 0x11B
#define COMMENT_REDIRECT 0x11C
对视频而言,我们需要设置一个区域来显示视频,也就是设定PLAYER_VIEWPORT.注意此处的rect结构体的定义,不同于我们使用的 RECT.其定义如下:
typedef struct rect
{
int x;
int y;
int Width;
int Height;
} rect;
对于图像的旋转(IF_OPTION_ROTATE)放大缩小(IF_OPITION_ZOOM)操作可以参考interface.c中 Command函数的使用。
视频驱动的选择可以通过 PLAYER_VOUTPUTID参数设置,具体参考代码。
最后,使用完插件后,我们需要卸载它们。具体操作如下:
if(Context()->Wnd)
{
NodeRegSaveValue(0,REG_INITING,NULL,0,TYPE_INT);
NodeRegSave((node*)myplayer);
Context()->Error.Func = NULL;
ArrayClear(&VOutput);
ArrayClear(&AOutput);
Context_Wnd(NULL);
}
Context_Done();