QuickTime’s Strange API

A while back one of our projects at work needed a plug-in for Unity to play QuickTime movies in the scene. It worked out well; the plug-in took me several days to implement, including one false start where I tried to superimpose a standard QuickTime view, minus the controls, over top of the running Unity scene. That approach didn’t work out because it behaved differently depending on whether it was run in full-screen or windowed, and it was ugly besides.

I ended up taking ideas from the Apple examples of rendering frames from a playing movie to an OpenGL texture, and combining that with the existing Unity plug-in example of rendering arbitrary data to a texture. I wrote about it in more detail already.

Recently it came up that I ought to provide a way of looping the movie’s playback, meaning in this context that when it reached the end, it would simply start over from the beginning and continue to play. I found Movie Toolkit’s SetMoviePlayHints, but after setting the looping flag, it still didn’t loop, so I google’d around a bit. I have yet to read a definitive answer, but it seems like looping a movie is the responsibility of the controller, whether that is Apple’s Movie Controller, or one you write yourself.

However, I can’t use a MovieController because as soon as I create one, even if I use the mcNotVisible flag to draw it, I have to give it a rect when I create it, and since I’m playing this movie to an offscreen bitmap through a GWorld, the rect’s origins are at 0,0.

The workaround is to continue using the primitive toolkit calls to play the movie, and when it reaches the end, send it back to the beginning and play it again. Ugh!

This entry was posted in Uncategorized and tagged . Bookmark the permalink.