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

Adding New Capabilities to the QT<strong>Kit</strong>Player Application<br />

2. Next, you want to add these initializations for your movie drawer items. Insert these lines:<br />

-(void)awakeFromNib<br />

{<br />

// initialize movie drawer items<br />

[self setDurationDisplay];<br />

[self setNormalSizeDisplay];<br />

[self setCurrentSizeDisplay];<br />

[self setSource:[self fileName]];<br />

}<br />

3. You want to return the mDrawer instance variable. Insert these lines before you add your setters,<br />

in a block identified as Getters:<br />

- (id)drawer<br />

{<br />

return mDrawer;<br />

}<br />

4. Now you want to add the following block of code, which enables you to read the movie. This is<br />

also where you install the movie action callback. Add these lines:<br />

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

{<br />

BOOLsuccess = NO;<br />

// read the movie<br />

if ([QTMovie canInitWithFile:fileName])<br />

{<br />

if ([type isEqualTo:@"MovieDocumentData"])<br />

{<br />

NSData*data = [NSData dataWithContentsOfFile:fileName];<br />

[self setMovie:[QTMovie movieWithData:data error:nil]];<br />

}<br />

else<br />

{<br />

[self setMovie:((QTMovie *)[QTMovie movieWithFile:fileName<br />

error:nil])];<br />

}<br />

}<br />

}<br />

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

if (success)<br />

{<br />

[self installMovieIdleCallback];<br />

}<br />

return success;<br />

5. Next, you need to install a movie controller action filter. If the movie is successfully created, the<br />

callback is installed. To get the controller from the movie and set the movie control filter, add<br />

this block of code:<br />

-(void)installMovieIdleCallback<br />

{<br />

74 Adding Code To Your QT<strong>Kit</strong>Player Project<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!