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

1. Insert the following line of code in the @interface directive block after your export outlet<br />

declarations. This enables you to specify the movie attributes for your NSDrawer object:<br />

IBOutlet NSDrawer *mDrawer;<br />

2. Add the following code (also in the @interface block) to specify the drawer elements for your<br />

movie attributes:<br />

IBOutlet NSTextField *mCurrentSize;<br />

IBOutlet NSTextField *mDuration;<br />

IBOutlet NSTextField *mNormalSize;<br />

IBOutlet NSTextField *mSourceName;<br />

IBOutlet NSTextField *mTimeDisplay;<br />

3. Define a getter for your drawer with the following line of code:<br />

- (id)drawer;<br />

4. Add to your IBActions to toggle the drawer open and closed, with the following line of code:<br />

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

5. Insert the following methods before the @end directive in the file:<br />

- (void)setDurationDisplay;<br />

- (void)setNormalSizeDisplay;<br />

- (void)setCurrentSizeDisplay;<br />

- (void)setSource:(NSString *)name;<br />

- (void)setTimeDisplay;<br />

6. Add these two methods to install and remove the movie callback before the @end directive in the<br />

file:<br />

-(void)removeMovieIdleCallback;<br />

-(void)installMovieIdleCallback;<br />

Adding Code To Make the Drawer Work<br />

In this next sequence of steps, you’ll be adding a larger chunk of code to your MovieDocument.m<br />

implementation file.<br />

To begin, open the MovieDocument.m file in your Xcode project. You’ll add the following blocks of<br />

code to your file. Just follow these steps:<br />

1. After your import and #define statements, add this line of C code to set your timer display. You<br />

pass your movie document in the refcon parameter and that gives you a way to call the<br />

setTimeDisplay: method. This is the function prototype you add:<br />

pascal Boolean MyActionFilter (MovieController mc, short action, void* params,<br />

long refCon);<br />

As the movie is being serviced by <strong>QuickTime</strong>, the movie controller component calls your action<br />

filter procedure each time the component receives an action for its movie controller. You use the<br />

idle action in your filter procedure to update your timer display.<br />

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