|
播放.avi文件的三种方法
1) You can use CAnimateCtrl :-
-------------------------------
CAnimateCtrl m_Animate;
m_Animate.Create( WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT |
ACS_CENTER,CRect(10,10,200,200),this,NULL);
m_Animate.Open("D:\\Test\\ok1.avi");
m_Animate.Play(0, -1, -1);
The header file to include
#include mmsystem.h
The library to include in your project settings.
Library : Winmm.lib
Disadvantages :- Can play ONLY uncompressed .avi files. For Eg. Will not work
with Globe.avi.
2) Use mciSendString :-
-----------------------
::mciSendString("open D:\\Girish\\Globe.avi",NULL,NULL,NULL);
::mciSendString("play D:\\Girish\\Globe.avi",NULL,NULL,NULL);
Header file to include :-
#include mmsystem.h
Library to include :-
Library : Winmm.lib
3) Use VFW :-
-------------
HWND hMCI;
TCHAR szFile[] = "D:\\Girish\\Globe.avi";
hMCI = MCIWndCreate(m_hWnd,AfxGetApp()->m_hInstance,
MCIWNDF_SHOWNAME|MCIWNDF_NOMENU, NULL);
if (MCIWndOpen(hMCI,szFile, 0) != 0)
{
MessageBox("Unable to play AVI!","Error!");
MCIWndDestroy(hMCI);
}
Header file to include :-
#include "vfw.h"
Library to include :-
Library : vfw32.lib
p.s.To add a library to your application, you can use the PROJECT menu and in
it , select the SETTINGS menu item.
In the dialog that appears, select the LINK Tab. In that, type Winmm.lib in
the textbox named Object/Module libraries.
All luck and have a great time.
|