;
}
如果是URL文件,调用OpenURLMovie,该函数跟OpenLocalMovie区别主要在于不用NewMovieFromFile而用NewMovieFromDataRef来得到句柄。
一般电影在创建完Movie Controller后最好调用PrePrerollMovie。
void CQuickTime::CreateNewMovieController(HWND hwnd, Movie theMovie, MovieController *theMC)
{
……
PrePrerollMovie(theMovie, GetMovieTime(theMovie, NULL), GetMoviePreferredRate(theMovie), NewMoviePrePrerollCompleteProc(QTPrePrerollCompleteProc), (void *)m_hViewWnd);
}
3.2.3关闭电影
void CQuickTime::CloseMovie(void)
{
if (m_MC)
{
DisposeMovieController(m_MC);
}
if (m_Movie)
{
DisposeMovie(m_Movie);
}
m_Movie = NULL;
m_MC = NULL;
}
3.2.4建立和取消电影窗口关联
int CQuickTime::OnMovieWindowCreate(HWND hWnd, CREATESTRUCT *lpCreateStruct)
{
if ( hWnd != NULL)
{
m_hViewWnd = hWnd; // the view''s hwnd
// Create GrafPort <-> HWND association
CreatePortAssociation(m_hViewWnd, NULL, kQTMLHandlePortEvents);
}
return 0;
}
void CQuickTime::OnMovieWindowDestroy()
{
if(m_Movie)
AbortPrePrerollMovie(m_Movie,noErr);
CGrafPtr windowPort = NULL;
// close any movies before destroying PortAssocation
CloseMovie();
// Destroy the view''s GrafPort <-> HWND association
if (m_hViewWnd)
windowPort = (CGrafPtr)GetHWNDPort(m_hViewWnd);
if (windowPort)
DestroyPortAssociation(windowPort);
}
3.2.5控制电影播放
笔者用控制MCDoAction来控制播放,这样可以得到播放的状态,当然也可以调用StartMovie、StopMovie等api函数。例如,
void CQuickTime::Play()
{
if(m_Mov