ADC Home > Reference Library > Technical Q&As > QuickTime > QuickTime Component Creation >

Movie Export Components - Supporting a MovieProgressProc


Q: I'm working on a Movie Export Component which encodes and writes data to a file. This process takes some time and I'd like to support a progress procedure. I've read about the MovieProgressProc but it seems to only apply to functions like ConvertMovieToFile and PutMovieIntoTypedHandle. How do I support a ProgressProc in my Export Component?

A: Supporting a Progress Procedure in your Export Component is quite straightforward.

The application will supply a MovieProgressProc conforming to the prototype in Listing 1. This is the user function you will call from your component.

OSErr MyMovieProgressProc(Movie theMovie,
                          short message,
                          short whatOperation,
                          Fixed percentDone,
                          long  refcon);

Listing 1. Prototype for an application defined MovieProgressProc.

You will need to support the SetProgressProc selector and implement the SetProgressProc function in your Export Component. This allows your component to be called with the MovieExportSetProgressProc API.

ComponentCall (SetProgressProc)

Listing 2. Supporting the SetProgressProc selector.

QuickTime will then call your Export Component with the ProgressProc (a MovieProgressUPP) and refcon. Store this MovieProgressUPP and refcon in your component globals for later use.

pascal ComponentResult MyExport_SetProgressProc(
                                myExportGlobals  glob,
                                MovieProgressUPP proc,
                                long             refcon)
{
    if ((NULL == proc) || (-1 == proc)) return paramErr;

    glob->progressProc = proc;
    glob->progressProcRefCon = refCon;

    return noErr;
}

Listing 3. Export component SetProgressProc implementation.

During the export process (when your component is doing its work), call the progress procedure using InvokeMovieProgressUPP making sure to supply the appropriate messages and updated percentage values to indicate your progress.

The message parameter should be set to one of the following values:

  • movieProgressOpen - your exporter is starting long operation, this must always be the first message.
  • movieProgressUpdatePercent - relative completion of the operation.
  • movieProgressClose - export operation done, this must be the last message.

The whatOperation parameter should be set to reflect the export operation:

  • progressOpExportMovie - export operation.
InvokeMovieProgressUPP(
        NULL,                  // movie
        movieProgress...,      // movieProgressOpen,
                               // movieProgressUpdatePercent
                               // or movieProgressClose
        progressOpExportMovie, // exporting
        myPercentDone,         // a fixed value 1.0 == 100% done
        store->progressProcRefCon,
        glob->progressProc);

Listing 4. Calling the MovieProgressProc from an Export Component

Application developers should note that the "Default Progress Proc" value of -1 cannot be used with MovieExportSetProgressProc. This API requires that you supply a valid callback function.

References:


[Jan 31 2003]


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.