In QuickTime 6 neither the NewMoviesFromProperties function nor the audio and visual contexts are available. The graphics destination is the current graphics port, the audio output is the default output device, and recommended practice is to instantiate the movie using NewMovieFromDataRef.
Setting a Graphics Destination in QuickTime 6 and Earlier
Specifying a Movie Data Source Using a Data Reference
Getting a Movie Using NewMovieFromDataRef
In QuickTime 6 and earlier, a movie is always instantiated using the application’s current graphics port, or GWorld. If you want to render to a different GWorld, you must change it by calling SetMovieGWorld after the movie is instantiated.
Your program’s graphics port must be valid when the movie is created, even if the movie is sound-only. The graphics port must remain valid for the life of the movie (or until you set a different valid graphics port for the movie using SetMovieGWorld). To test for a valid graphics port, call GetGWorld.
A graphics port is automatically created and assigned when you create a window in the Mac OS.
In the Windows OS, you create a valid graphics port using NewGWorld and associate it with your window by calling CreatePortAssociation. (You also need to call DestroyPortAssociation before disposing your window.) You can create a GWorld that corresponds to your window’s current graphics device in the Windows OS by calling GetNativeWindowPort.
In QuickTime 6, you create a data reference for your movie data source (file, URL, pointer, or handle) and pass the data reference to the function NewMovieFromDataRef.
Note: Creating a new movie without a preexisting data source is a special case; use the function NewMovie to create an empty movie and NewMovieFromUserProc to create a movie whose data will be generated dynamically. These functions are discussed in depth in QuickTime Movie Creation Guide.
To create a data reference for the movie data source, use one of the QTNewDataReferencers> functions:
There are functions you can use to create a data reference from a string representing a file system reference, a directory, a full path, or a URL. There are also functions for creating a data reference directly from a CFURL, FSRef, or FSSpec. Use the utility function that is most convenient for you. For example, if you have a C string that indicates a URL, convert the C string to a CFString and call QTNewDataReferenceFromURLCFString. Windows programmers with a native Windows pathname might find it more convenient to create a CFString and call QTNewDataReferenceFromFullPathCFString.
All of these functions take a pointer for a data reference and a pointer for a reference type. On return, these pointers indicate the location and type of data reference created; you pass these pointers to NewMovieFromDataRef.
Note: These NewDataReference... utility functions were added in QuickTime 6.4. You can create a data reference manually to create data references using earlier versions of QuickTime 6. For details, see the code sample “Example of Getting a Movie and Monitoring the Load State” and Technical Note TN1195, Tagging Handle and Pointer Data References in QuickTime.
The data reference can point to either a QuickTime movie or to media data in a non-QuickTime format that QuickTime can import in place. If the data source does not contain a stored movie, QuickTime attempts to create a movie by searching the list of available movie import components based on the file type, MIME type, or filename extension of the data source.
If the data source is a buffer in memory, and is not a QuickTime movie, an additional step is required. Because your data reference is a pointer or handle, there is no MIME type, file type, or extension associated with it. In this case, you need to “tag” your data reference by adding one or more datarefextensions, such as a filename, file type, or MIME type, so QuickTime knows what type of importer is needed. For details, see Technical Note TN1195 Tagging Handle and Pointer Data References in QuickTime.
NewMovieFromDataRef is a generalized routine that can instantiate a movie from most data sources. If you are writing an application that needs to run in QuickTime 6, it is recommended that you use NewMovieFromDataRef to instantiate the movie.
To use NewMovieFromDataRef, you first create a data reference to the movie data source. For details, see “Specifying a Movie Data Source Using a Data Reference.”
NewMovieFromDataRef also accepts a set of movie instantiation flags, indicating such things as whether the movie is active immediately, whether to query the user if QuickTime is unable to locate data files specified in the movie, and so on. For additional details, see NewMovieFromDataRef.
Listing 1-4 shows an example of creating a data reference and passing it to NewMovieFromDataRef, along with the movie instantiation flags.
Listing 3-4 Creating a data reference and calling NewMovieFromDataRef
// This function takes a CFStringRef to a full path and |
// attempts to get a movie from the specified file |
Booolean OpenMovie(CFStringRef inPath) |
{ |
Movie myMovie = NULL; |
OSType myDataRefType; |
Handle myDataRef = NULL; |
short myResID = 0; |
OSErr myErr = noErr; |
... |
// create the data reference |
myErr = QTNewDataReferenceFromFullPathCFString(inPath, kQTNativeDefaultPathStyle, |
0, &myDataRef, &myDataRefType); |
if (myErr != noErr) goto bail; |
// get the Movie |
myErr = NewMovieFromDataRef(&myMovie, |
newMovieActive | newMovieAsyncOK, |
&myResID, myDataRef, myDataRefType); |
if (myErr != noErr) goto bail; |
// dispose of the data reference handle - we no longer need it |
DisposeHandle(myDataRef); |
// remember to call DisposeMovie when done with the returned Movie |
... |
} |
Last updated: 2005-08-11