
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
DRAWING
Start a movie correctly
This is probably more of an Inside Mac question than an FB question but let me try.
I've written a small QT video player (with the help of several list members!) that plays a QT movie in a window without a controller. It is not event driven but just loops and finishes.
The first time the movie is played, the soundtrack starts right away but the video doesn't come on for a second or two. The second and subsequent times the movie is played, both video and audio play from the beginning.
I'd like to not miss the first few seconds of video. Any ideas?
LONG IF FN ENTERMOVIES = _NoErr
LONG IF FN OPENMOVIEFILE(fsSpec,MovieResRefNum%,_FSRdPerm) = _NoErr
LONG IF FN NEWMOVIEFROMFILE(movieptr&,MovieResRefNum%,resID%,resName$,1,dataRefChgd%) = _NoErr
LONG IF FN CLOSEMOVIEFILE(movieresrefnum%) =3D_NoErr
CALL GETMOVIEBOX(movieptr&,rect%)
CALL OFFSETRECT(rect%,-boxL%,-boxT%)
CALL SETMOVIEBOX(movieptr&,rect%)
WINDOW #_videoboxwindow, "", (h,v)-(h1,v1),_dialogplain
CALL GETGWORLD(CGrafPtr&,CurDev&)
CALL SETMOVIEGWORLD(movieptr&,CGrafPtr&,0)
CALL GOTOBEGINNINGOFMOVIE(movieptr&)
OsErr =3D FN PREROLLMOVIE(movieptr&,0,&1000)
CALL STARTMOVIE(movieptr&)
END IF
END IF
END IF
END IF
LONG IF movieptr&
DO
CALL MOVIESTASK(movieptr&,33)
UNTIL FN ISMOVIEDONE(movieptr&)
END IF
END FN
Sure. You need to "preroll" the video. This essentially tells QuickTime that you are about to start the video, and that it should get things ready. Use FN PREROLLMOVIE with your movie, a time value of zero, and a rate of 1.
You have;
CALL GOTOBEGINNINGOFMOVIE(movieptr&)
OsErr = FN PREROLLMOVIE(movieptr&,0,&1000)
CALL STARTMOVIE(movieptr&)
I think it's advisable to add _another_ GOTOBEGINNINGOFMOVIE after the PREROLL. The objective is to "preload" a couple of seconds of the movie in memory, but I think your pointer is left "elsewhere" other than the first frame by this call. Calling STARTMOVIE makes it start playing at the beginning, but it takes a moment for the video pointer to "catch up" to the audio. Presetting it at the start _might_ help.
If this doesn't work, and you have access to the movie in question, you might check the interleaving of the tracks to make sure the video is "up front"; or even add a second of "silence" to the beginning of the movie, with no video.
This may all be way off base; I haven't done anything with movies in a couple of years...
|