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

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

}<br />

self = nil;<br />

}<br />

return self;<br />

5. Insert the following code to handle deallocation of memory and notifications:<br />

- (void)dealloc<br />

{<br />

[[NSNotificationCenter defaultCenter] removeObserver:self];<br />

[self setMovie:nil];<br />

[super dealloc];<br />

}<br />

6. To deal with NSMenu validations for enabling and disabling of menu items, insert this chunk of<br />

code:<br />

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

{<br />

BOOL valid = NO;<br />

SEL action;<br />

// init<br />

action = [menuItem action];<br />

// validate<br />

if (action == @selector(doExport:))<br />

valid = (mMovie != nil);<br />

else if (action == @selector(doSetFillColorPanel:))<br />

valid = YES;<br />

else if (action == @selector(doShowController:))<br />

{<br />

[menuItem setState:([mMovieView isControllerVisible] ? NSOnState :<br />

NSOffState)];<br />

valid = YES;<br />

}<br />

else if (action == @selector(doPreserveAspectRatio:))<br />

{<br />

[menuItem setState:([mMovieView preservesAspectRatio] ? NSOnState :<br />

NSOffState)];<br />

valid = (mMovie != nil);<br />

}<br />

else if ((action == @selector(doLoop:)) && mMovie)<br />

{<br />

[menuItem setState:([[mMovie attributeForKey:QTMovieLoopsAttribute]<br />

boolValue] ? NSOnState : NSOffState)];<br />

valid = YES;<br />

}<br />

else if ((action == @selector(doLoopPalindrome:)) && mMovie)<br />

{<br />

if ([[mMovie attributeForKey:QTMovieLoopsAttribute] boolValue])<br />

{<br />

[menuItem setState:([[mMovie<br />

attributeForKey:QTMovieLoopsBackAndForthAttribute] boolValue] ? NSOnState :<br />

NSOffState)];<br />

valid = YES;<br />

}<br />

Adding Code to MovieDocument.m 49<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!