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

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

3. Add a larger chunk of code to your MovieDocument.m implementation file. This will involve<br />

working with a callback mechanism from the <strong>QuickTime</strong> C API. The goal is to learn how you can<br />

tap into the rich library of the <strong>QuickTime</strong> C API, when you want to add specific functionality to<br />

your Cocoa project that may not be available, for whatever reason, in the Cocoa API.<br />

Project Complexity<br />

The complexity of the project comes with the addition of a callback mechanism from the <strong>QuickTime</strong><br />

C API.<br />

Basically, as the movie is playing, you need a mechanism to update the timer field in the drawer. The<br />

movie controller component calls your action filter function each time the component receives an<br />

action for its movie controller. In your action filter, you will use the idle action (mcActionIdle) to<br />

update your time display. The idle action is sent continuously while the movie is being serviced.<br />

You could do a similar thing with an NSTimer, but the action filter technique is a bit easier to implement.<br />

The function prototype for the <strong>QuickTime</strong> C callback mechanism is defined as follows:<br />

Boolean MyMCActionFilterWithRefConProc<br />

( MovieController mc,<br />

short action,<br />

void *params,<br />

long refCon );<br />

The MyMCActionFilterWithRefConProc function responds to the actions of a movie controller with<br />

a reference constant. The parameters specify the movie controller (mc) for the operation, the movie<br />

controller action (action), a pointer to a structure that passes information to the callback, and a<br />

reference constant (refCon) that your code supplies to your callback. Your QT<strong>Kit</strong>Player application<br />

can invoke these actions by calling MCDoAction. An action filter function will receive any of the<br />

controller actions sent to it.<br />

You’ll add this callback to the code in your MovieDocument.m implementation file. The way to<br />

accomplish this is explained in detail in the section “Adding Code To Make the Drawer Work” (page<br />

73).<br />

Class Model<br />

When you’ve completed all these tasks, you’ll see the class model of your QT<strong>Kit</strong>Player code in Xcode<br />

2.0, as shown in Figure 4-3. The class model includes a list of the MovieDocument instance variables<br />

you’ll add to your QT<strong>Kit</strong>Player project and a visualization of their connections and inheritance paths.<br />

Tasks to Accomplish 63<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!