Overview

In QuickTime you play media of any kind—sound, video, still images, text, or animation—by creating a movie data structure in memory and playing the movie.

Movies

The movie is the fundamental data structure in QuickTime; it describes what media to present, where the media samples are located, and how and when to present them (duration, sequencing, compositing, layering, rotation and scaling, sound volume, and so on).

Playing a movie typically generates graphic output in a window, but other kinds of output are possible: a sound-only movie may not create a visible display; a movie may display using the whole screen instead of a window, or may render to an offscreen buffer or an external device such as a Firewire video recorder. Video output can be rendered directly to video memory as a series of OpenGL textures. Audio output can be directed to an external device or recorder.

In addition to playing existing QuickTime movies, QuickTime can automatically play media in over forty different formats and file types, including AIFF, WAVE, and MP3 audio; MPEG-1, MPEG-4, 3GPP, and DV video; JPEG, PNG, and GIF still images; and Flash and various other animation formats. For a full list, see File Types that QuickTime Can Open as Movies.

The movie or other media to be played can be stored in a file, a stream, or a buffer in memory, and can be accessed through a data reference such as a path and filename, file specification, URL, pointer, or handle.

Movies are typically stored in QuickTime movie files. The movie data samples are stored separately, either elsewhere in the same file or in other storage locations. When you get a movie from a QuickTime movie file, QuickTime copies the stored movie data structure into memory, then resolves the references to the sample data.

When you get a movie from a source other than a QuickTime movie file, such as a native MP3 or JPEG file, QuickTime creates a new movie describing the sample data; this is called importinginplace, because the sample data is not modified but remains in place. The import process consists of creating a movie data structure that describes the existing media.

Whether the movie is copied from storage or created on the fly by importing in place, it results in a data structure in memory that references data stored elsewhere. Once the data references are resolved, the movie can be played.

If the data must be downloaded from a remote storage location, the movie may go through the following load states:

To get and play a movie, take the following steps:

  1. Choose a graphics destination, such as a visual context, a graphics world, or the default graphics port.

  2. Optionally create an audio context if you want to select an audio output other than the default.

  3. Specify a movie data source, such as a local file, a URL, or a block of memory referenced by a pointer or handle.

  4. Get a movie from the source using one of several NewMovieFrom... functions, preferably NewMovieFromProperties. These functions create a movie in memory and return a valid movie reference. Use this reference with any function that takes a movie as a parameter.

  5. Attach a movie controller component to the movie for playback.

  6. Monitor the load state until the movie is playable, can play through without interruption, or is complete.

  7. Grant the movie controller idle time. This can be automatic (using an HIMovieView), semiautomatic (using Carbon event timers), or manual (by granting idle time during your event loop).

Programmers working in version 10.4 and later of the Mac OS can use an HIMovieView object to control movie playback; this is the recommended technique.

Programmers working in the Windows OS or Mac OS 9 need to use the ActiveX control (Windows only) or a movie controller component. If you use an ActiveX control or a movie controller component, you need to implement a run loop that grants idle time to the control to enable movie playback.

Programmers working in QuickTime 6 for Mac OS X can use a Carbon movie controller. This is less desirable than using an HIMovieView.