« Twitter via CURL upda… | Home | MBS Xojo / Real Studi… »

QTkitMovieMBS and Movieplayer trouble

Today we had an interesting issue. A client uses our QTkitMovieMBS class to load a movie from disk. Than he queries the movie object and assigns to Movieplayer. The code looks like this:

dim qtkm as QTKitMovieMBS = QTKitMovieMBS.LoadMovieFromFile(mvFile,e)
MoviePlayer1.movie = qtkm.movie

It does work fine in Carbon, but fails for Cocoa. In Cocoa, you get a couple of new threads for each time you do this and that is very bad. On the long run you either run out of CPU time (app gets slower) or out of memory (Crash).

The reason is under the hood. We convert from QTMovie in QTKit to a regular Movie in old QuickTime API. In Cocoa targets Xojo itself uses QTKit for the MoviePlayer, so they convert from the Movie back to a QTMovie. And somewhere here the cleanup does not work correct. So for each movie a few threads are started (audio, video, decoder) and they are not closed when the movie is destroyed.

The solution is to use the existing QTKitMovieViewMBS class in our plugins:

dim qtkm as QTKitMovieMBS = QTKitMovieMBS.LoadMovieFromFile(mvFile,e)
dim q as QTKitMovieViewMBS = MoviePlayer1.QTKitMovieViewMBS
q.movie = qtkm

So here we query the MovieView for the movieplayer and assign the video directly. This way Xojo does not know about the change. Things like autoResize don't work. But it solves the thread problem so far.

The new functions used here will be part of next plugin prerelease.
13 06 13 - 11:10