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 />

// export<br />

IBOutlet NSView *mExportAccessoryView;<br />

IBOutlet NSPopUpButton *mExportTypePopUpButton;<br />

// movie document<br />

QTMovie *mMovie;<br />

}<br />

The first line defines the MovieDocument class and specifies that it inherits from the NSDocument<br />

class. The first four statements declare the outlets you set up and connected in Interface Builder.<br />

The movieWindow instance variable, for example, points to the NSWindow object while the<br />

movieView instance variable points to the QTMovieView object. The last line declares that the<br />

mMovie instance variable points to the QTMovie object.<br />

3. Define a class method with the following line of code:<br />

+ (id)movieDocumentWithMovie:(QTMovie *)movie;<br />

4. To initialize movies, add this code line:<br />

- (id)initWithMovie:(QTMovie *)movie;<br />

5. For the NSMenu validation protocol, which returns a BOOL value, as it validates the menu items<br />

in your project, add this:<br />

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;<br />

6. The following line of code, which enables you to set a movie to the QTMovie object using the<br />

setMovie: method, is one of the most common you’ll use in building projects with the <strong>QuickTime</strong><br />

<strong>Kit</strong> framework. Add it:<br />

- (void)setMovie:(QTMovie *)movie;<br />

7. Insert the following block of action method declarations in your MovieDocument.h file:<br />

- (IBAction)doExport:(id)sender; // run the export sheet<br />

- (IBAction)doSetFillColorPanel:(id)sender; // update the fill color<br />

- (IBAction)doSetFillColor:(id)sender;<br />

- (IBAction)doSetPosterTime:(id)sender;<br />

- (IBAction)doShowController:(id)sender;//toggle controller visibility<br />

- (IBAction)doPreserveAspectRatio:(id)sender;// toggle aspect ratio<br />

- (IBAction)doLoop:(id)sender; // toggle looping<br />

- (IBAction)doLoopPalindrome:(id)sender; // toggle palindrome looping<br />

- (IBAction)doClone:(id)sender;<br />

8. To handle NSDocument overrides, add the following lines of code:<br />

- (NSString *)windowNibName;<br />

- (void)windowControllerDidLoadNib:(NSWindowController*)windowController;<br />

- (NSData *)dataRepresentationOfType:(NSString *)docType;<br />

- (BOOL)writeWithBackupToFile:(NSString *)fullDocumentPath ofType:(NSString<br />

*)type saveOperation:(NSSaveOperationType)saveOperation;<br />

- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type;<br />

- (void)printShowingPrintPanel:(BOOL)showPanels;<br />

9. Insert the following method before the @end directive in the file:<br />

Adding Code to the MovieDocument Class Interface 47<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!