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.
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:
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.
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.