QuickTime on Windows - Movies

 

 

 

Apple has a really good example class for MFC programming - CQuickTime -- very helpful!

I wanted to load a movie with a URL. There are a few good examples out there... so here's what I learned.

Movie LoadMovieFromURL( const UInt8* url, CFIndex len, Rect* bounds )
{ // you have to set the port first - MacSetPort, CreatePortAssociation
CFURLRef urlRef = ::CFURLCreateWithBytes( null, url, len, kCFStringEncodingUTF8, null );
OSErr error;

if( null == urlRef )
return null;

Movie movie = null;
Handle dataRef;
OSType dataRefType;
error = ::
QTNewDataReferenceFromCFURL( urlRef, 0, &dataRef, &dataRefType );

if( noErr == error )
{
short movieId;
error = ::NewMovieFromDataRef( &movie, 0, &movieId, dataRef, dataRefType );

if( noErr == error )
{
::GetMovieBox( movie, bounds );
}
}

::CFRelease( urlRef );

return movie;
}


Before calling this routine, you need to set the graphics port. You can create a graphics port for your Windows HWND with 
CreatePortAssociation

With loading images, I didn't use a CFURLRef. I am here. Why? Just practicing how to skin cats many ways. Handy to know when things don't work.

I make the movie controller with the following routine:
MovieController MakeMovieController( Movie movie, CWnd* wnd, Rect* bounds )
{
Rect theMovieRect;
CRect box;

::SetMovieBox( movie, bounds );

wnd->GetClientRect( box );

theMovieRect.left = 0;
theMovieRect.top = 0;
theMovieRect.right = box.Width();
theMovieRect.bottom = box.Height();

// Attach a movie controller
return ::NewMovieController( movie, &theMovieRect, mcTopLeftMovie );
}


This will put the movie in the top left corner of the CWnd. This works for me for now. I'm going to center the movie eventually.

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值