QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
C H A P T E R 3<br />
Extending the QT<strong>Kit</strong>Player Application<br />
// update/save<br />
if (saveOperation == NSSaveOperation)<br />
success = [mMovie updateMovieFile];<br />
else<br />
success = [super writeWithBackupToFile:fullDocumentPath ofType:type<br />
saveOperation:saveOperation];<br />
}<br />
return success;<br />
12. Add these lines of code:<br />
- (NSData *)dataRepresentationOfType:(NSString *)docType<br />
{<br />
return [mMovie movieFormatRepresentation];<br />
}<br />
13. Add these lines to handle reading the movie from a file:<br />
- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type<br />
{<br />
BOOL success = NO;<br />
NSData *data;<br />
}<br />
// read the movie<br />
if ([QTMovie canInitWithFile:fileName])<br />
{<br />
if ([type isEqualTo:@"MovieDocumentData"])<br />
{<br />
data = [NSData dataWithContentsOfFile:fileName];<br />
}<br />
}<br />
else<br />
{<br />
[self setMovie:((QTMovie *)[QTMovie movieWithFile:fileName])];<br />
success = (mMovie != nil);<br />
}<br />
return success;<br />
14. The following chunk of code is intended to deal with opening movies and other media that<br />
<strong>QuickTime</strong> “understands” using an instance method and setting a flag. Add these lines:<br />
- (id)openDocumentWithContentsOfFile:(NSString *)fileName<br />
display:(BOOL)displayFlag<br />
{<br />
// first check whether we already have a document for this file<br />
NSDocumentController *sharedDocController = [NSDocumentController<br />
sharedDocumentController];<br />
MovieDocument *movieDocument = [sharedDocController<br />
documentForFileName:fileName];<br />
if (movieDocument)<br />
{// we've got one, just bring it forward<br />
if (displayFlag)<br />
{<br />
52 Adding Code to MovieDocument.m<br />
2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.