02.04.2013 Views

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C H A P T E R 3<br />

Extending the QT<strong>Kit</strong>Player Application<br />

[movieDocument showWindows];<br />

}<br />

}<br />

else<br />

{// we must create a new document.<br />

// we always create a movie document regardless of type<br />

// init<br />

movieDocument = [[[MovieDocument allocWithZone:[self zone]]<br />

initWithContentsOfFile:fileName ofType:@"mov"] autorelease];<br />

}<br />

// set up the document<br />

if (movieDocument)<br />

{<br />

// add the document<br />

[sharedDocController addDocument:movieDocument];<br />

// set up the document<br />

if ([sharedDocController shouldCreateUI])<br />

{<br />

[movieDocument makeWindowControllers];<br />

if (displayFlag)<br />

{<br />

[movieDocument showWindows];<br />

}<br />

}<br />

}<br />

}<br />

return movieDocument;<br />

15. Add the following code to locate the file to be opened:<br />

- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename<br />

{<br />

BOOL isDir = NO;<br />

}<br />

[[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir];<br />

if (isDir)<br />

{<br />

return YES;<br />

}<br />

else<br />

{<br />

return [QTMovie canInitWithFile:filename];<br />

}<br />

16. Add this code to filter files through an Open dialog and display them:<br />

- (void)openDocument:(id)sender {<br />

NSOpenPanel *openPanel = [NSOpenPanel openPanel];<br />

[openPanel setDelegate:self];<br />

[openPanel setAllowsMultipleSelection:NO];<br />

// files are filtered through the panel:shouldShowFilename: method above<br />

Adding Code to MovieDocument.m 53<br />

2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!