Feb 00 QTToolkit
Volume Number: 16
Issue Number: 2
Column Tag: QuickTime Toolkit
Movie Controller Potpourri
by Tim Monroe
More Adventures with QuickTime's Movie Controllers
In the previous article, we learned how to open QuickTime movies and display them in
windows on the screen. We also learned how to create movie controllers and pass
events to them so that the user can interact with the movies in the most basic ways.
For normal "linear" QuickTime movies, these basic interactions include starting and
stopping the movie, moving quickly forward or backward in the movie, adjusting the
volume of the sound track, and performing simple editing operations on the movie. For
QuickTime VR movies, the basic interactions include changing the pan and tilt angles,
zooming in or out, moving from one node to another, and displaying the visible hot
spots. All of this interaction is provided, with virtually no programming on our part,
by the movie controller associated with the movie.
In this article, we're going to continue working with movie controllers. Now that we've
done all the work necessary to associate a movie controller with a movie and to draw
the movie and movie controller in a window on the screen, there is a tremendous
amount of "low-hanging fruit" that we can pick with a very small amount of code. Here
we'll see how to hide and show the movie controller bar, hide and show particular
buttons in the bar, attach a pop-up menu to the recently-introduced custom button in
the controller bar, and perform several other tasks on the controller bar. Toward the
end of this article, we'll also throw in a few goodies that are only slightly more
complicated, like getting a movie controller to open a URL in the user's default web
browser.
Along the way, we'll shift our focus slightly and take a look at movie user data, which
is some custom data that can be attached to a movie. You can use a movie's user data to
specify lots of information about a movie, including the initial position of the movie
window, the movie's looping state, and the movie's copyright information. This isn't
completely unrelated to our main topic in this article, because movie controllers and
movie user data are linked in one important way: for a movie to use a special movie
controller (that is, any controller other than the standard linear movie controller),
the movie's user data must include a piece of information that specifies which other
controller to use. When you call NewMovieController to associate a movie controller
with an open movie, QuickTime looks for that piece of user data and, if it finds it,
opens the specified movie controller. Here we'll see how we too can inspect that data
and use it for our own purposes.
Before we begin, it's worthwhile to emphasize once again the distinction between a
movie controller and a movie controller bar. A movie controller is a software
component that you can use to manage the user's interaction with a QuickTime movie. A
movie controller bar is a visible set of controls and other user-interface elements
that is displayed by a movie controller (usually along the bottom of the movie window)
and that provides some ways for the user to interact with the movie. The movie
controller typically supports some forms of user interaction that are not associated
with the controller bar (for instance, hitting the space bar starts or stops a linear
QuickTime movie). Moreover, it's possible to have a movie controller associated with a
movie but no visible movie controller bar (as we'll see shortly); even when the movie
controller bar is hidden, the user can still interact with the movie. This distinction
needs emphasizing only because it's not uncommon to hear people talk about the movie
controller when they really mean the movie controller bar.
Managing the Controller Bar
Showing and Hiding the Controller Bar
So let's get started picking some of that low-hanging fruit. One of the simplest things
we can do is hide the movie controller bar, with this single line of code:
MCSetVisible(myMC, false);
(Here myMC refers to a movie controller.) The MCSetVisible function sets the
controller bar to be visible or invisible, according to the Boolean value you pass it.
Figure 1 shows a movie window with the controller bar hidden.
Figure 1. A movie window with a hidden movie controller bar
Let's take a moment to define a couple of functions that call MCSetVisible with the
appropriate parameter, mainly to give ourselves a more uniform naming convention
and to make our code a bit more readable. Listing 1 defines the function
QTUtils_HideControllerBar and Listing 2 defines the opposite function,
QTUtils_ShowControllerBar.
______________________________
Listing 1: Hiding the controller bar
QTUtils_HideControllerBar
void QTUtils_HideControllerBar (MovieController theMC)
MCSetVisible(theMC, false);