Microsoft - The real reason for an iPhone SDK
Opening up the iPod API and Apples a la carte iPhone
The Joys and Troubles of Writing Software on top of the QuickTime API - with some sample code
/* ___________________________ The Old Way _______________________ */
// NOTE: keyIfError() is simply a error checking macro we use.
// Requires FSSpecs and active GWorld
keyIfError(OpenMovieFile(&aFSSpec, &aRefNum, fsRdPerm));
keyIfError(NewMovieFromFile(&aMovie, aRefNum, NULL, NULL, newMovieActive | newMovieAsyncOK, NULL));
CloseMovieFile(aRefNum);
aRefNum = 0;
/* ___________________________ The New Way _______________________ */
// First define these...
DataReferenceRecord aQTDataRef = {0};
Boolean isActive = true;
QTVisualContextRef aVisualContext = NULL;
QTNewMoviePropertyElement aMovieProperties[] = {
{kQTPropertyClass_DataLocation, kQTDataLocationPropertyID_DataReference, sizeof(aQTDataRef), &aQTDataRef, 0},
{kQTPropertyClass_NewMovieProperty, kQTNewMoviePropertyID_Active, sizeof(isActive), &isActive, 0},
{kQTPropertyClass_Context, kQTContextPropertyID_VisualContext, sizeof(aVisualContext), &aVisualContext, 0},
};
/* Just to note, it is not clear what the visual context is, but I assume we need this now so as not to crash. */
// Now Create the Data ref.
keyIfError(FSPathMakeRef(aPath, &aFSRef, NULL));
keyIfError(QTNewDataReferenceFromFSRef(&aFSRef, 0, &aQTDataRef.dataRef, &aQTDataRef.dataRefType));
// Wait. That does not work on Windows. So try this...
keyToSystemPascalString(aCPath, aPascalPath, sizeof(aPascalPath));
keyIfError(FSMakeFSSpec(0, 0, aPath, &aFSSpec));
keyIfError(QTNewDataReferenceFromFSSpec(&aFSSpec, 0, &aQTDataRef.dataRef, &aQTDataRef.dataRefType));
/* And since Windows programmers are so used to a Pascal path this makes sense. And again we are using those FSSpecs we are never to touch again so try again. */
// The real trick is this...
aCFStringPath = CFStringCreateWithCString(NULL, aCPath, kCFStringEncodingUTF8);
keyIfError(QTNewDataReferenceFromFullPathCFString(aCFStringPath, kQTNativeDefaultPathStyle, 0, &aQTDataRef.dataRef, &aQTDataRef.dataRefType));
CFRelease(aCFStringPath);
aCFStringPath = NULL;
/* Now raise your hand if you have ever seen any Apple sample code use Core Foundation classes on Windows. I could not find it. Hopefully this exists and I am just blind. Low and behold, this and the CFURL equivalents work, and give you an easy way to handle paths and start creating movies. */
// Now call...and don't forget we have a DataRef which we are not sure what it is in one of those properties.
keyIfError(NewMovieFromProperties(3, aMovieProperties, 0, NULL, &aMovie));
/* And now you have to call SetMovieGWorld() or the other equivalents which I am not sure what they are as I have not migrated my drawing to the only cross platform option of OpenGL. And GWorlds work in crazy hacked ways from HBITMAP's and CGContext's */
// Finally dispose of the DataRef...but wait there is not an compliment to QTNewDataReferenceFrom() functions. So you have to use the most intuitive. DisposeHandle to the pointer of one of the structs values
DisposeHandle(aQTDataRef.dataRef);
aQTDataRef.dataRef = NULL;
aHandler = OpenComponent(GetDataHandler(aQTDataRef.dataRef, aQTDataRef.dataRefType, kDataHCanRead));
anErr = GetMoviesError();