Nov 99 Getting Started
Volume Number: 15
Issue Number: 11
Column Tag: Getting Started
Getting Started with QuickTime
by Dan Parks Sydow
How a program displays a QuickTime movie and
movie-controller in a window
For years, QuickTime has been cool. Now, version 4 makes QuickTime amazing. With
QuickTime 4 your program's use of movies knows few bounds. As always, your
program can open a QuickTime movie in a window that includes aesthetically pleasing,
easy to use controls so that the user can play, pause, or step through the movie. But if
you're willing to get to know the Movie Toolbox (the movie-related functions that
make up this addition to the Macintosh Toolbox), your Mac program can do much more
with QuickTime. Streaming movies, special effects (such as transitions, blending, and
dimming), video and audio capture, sprites, and much, much more are all available to
you, the programmer. Sound exciting? Ready to get going? Not so fast! In this article
you won't learn how to implement these programming tricks. Instead, here you'll only
learn the basics of QuickTime programming. Getting Started's job isn't to delve deep
into the complicated -- it's to introduce and detail the basics of Toolbox technologies so
that you'll be ready to move on to those more complicated and really intriguing
technologies Apple has developed for Mac programmers. The things your program can
accomplish with QuickTime 4 are so interesting and remarkable, a number of articles
are necessary in order to convey to you the programming information you need. And
that's exactly what MacTech Magazine is doing. In fact, you'll find a QuickTime 4
article in this very issue
After reading this article you'll know how to check the user's machine for the presence
of QuickTime, initialize QuickTime, let the user select a movie to play, open a window
complete with controllers, and let the user make use of those controls to play (and
replay, and step through, and so forth) the displayed movie. Armed with this
knowledge, the material in this month's other QuickTime article -- and the material
in many subsequent MacTech Magazine QuickTime-related articles -- will certainly
be well within your reach.
QuickTime and the Movie Toolbox
On its own, QuickTime doesn't play movies. Instead, QuickTime enables applications
that are written with QuickTime in mind to play movies. To give programmers the
ability to add movie-playing features to their applications, Apple has added a number
of movie-related functions to the system software. Rather than dub this collection a
manager, Apple has instead called it another Toolbox -- the Movie Toolbox. Gaining a
knowledge of the routines in the Movie Toolbox is key to adding movie-playing
capabilities to your programs.
Initializations
Before your program jumps right in using QuickTime, it should verify that the user's
machine has the QuickTime extension installed (or that if installed, it isn't disabled)
and it should initialize the Movie Toolbox. The first task is accomplished with a call to
Gestalt(). Here's the code to use:
OSErr err;
long result;
err = Gestalt( gestaltQuickTime, &result );
if ( err != noErr )
DoError( "\pQuickTime not present" );
Recall from previous articles that when one of the many Apple-defined selector codes
is passed as the first parameter, Gestalt() fills in the second parameter with
information about the topic of the selector code. In this instance, the selector code is
gestaltQuickTime. The returned result will be the version of QuickTime that's on the
user's Mac. If your program will be making use of fancy techniques only available in,
say, version 4 of QuickTime, then you'll want to examine result to see if it holds a
value of 4. If your program isn't doing much more than standard movie playing, you