Adding a movie reference to a movie

Q: I'd like to add a reference for a movie to another movie, for example to "merge" two movies together so one will playback right after the other. Is this done with data references? Or do I use an alias approach? I'm confused. Please explain.

A: The easiest way to do this is with the Movie Toolbox Editing routine InsertMovieSegment. This function copies part of one movie to another. Simply call this function and specify which part of the destination movie you'd like copied to the source movie.

For example, to add a reference to some source movie to a destination movie use InsertMovieSegment as shown in the code snippet below:

Listing 1: Adding a movie reference using InsertMovieSegment.

void addMovieReference(Movie destMovie, Movie sourceMovie)
{
  TimeValue srcMovieDuration, destMovieDuration;
  OSErr err = noErr;

  srcMovieDuration = GetMovieDuration(sourceMovie);
  destMovieDuration = GetMovieDuration(destMovie);

   // add to destMovie a reference to sourceMovie
  err = InsertMovieSegment(
          sourceMovie,             // source movie
          destMovie,               // destination movie for the insert
          0,                       // insert from beginning of source movie
          srcMovieDuration,        // duration of source movie segment to insert
          destMovieDuration        // where to insert the source segment into the dest.
        );

  .
  .
  .
}

Also, call CopyMovieSettings if you wish to copy movie settings such as preferred rate and volume, and so on, from the source movie to the destination movie:

Listing 2: Using CopyMovieSettings to copy movie attributes.

err = CopyMovieSettings (srcMovie,
                         destMovie );

Note that some or all of the media of the source movie may be copied to the destination if one or more calls to BeginMediaEdits precede the call to InsertMovieSegment. For our purposes, we make certain that no such calls are made. In this case, only references to the actual media in the source movie to be stored in the destination movie will be copied. The actual media itself is not copied.

Finally, don't forget to call UpdateMovieResource (or UpdateMovieInStorage if the movie was created with CreateMovieStorage) for the destination movie to save your changes.

Adding a reference to a movie can also be accomplished using data references. However, this is a more complicated approach, and in this case we can get the same result using InsertMovieSegment.

For an example of how to create a reference to a movie using data references, see the Sample Code Project 'qtdataref'.

Document Revision History

DateNotes
2004-09-16Demonstrates how to add a reference for a movie to another movie

Posted: 2004-09-16


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.