Re: how to be informed that a movie is done playing?
Re: how to be informed that a movie is done playing?
- Subject: Re: how to be informed that a movie is done playing?
- From: Laurent Daudelin <email@hidden>
- Date: Thu, 08 Jan 2004 01:10:56 -0500
on 07/01/04 23:04, Daryn at email@hidden wrote:
>
Perusing the documentation and the mail lists, it seems that the only
>
way to tell when a movie/sound has stopped playing is to constantly
>
poll NSMovieView's isPlaying with a timer? I have an severe allergy to
>
polling, so surely there's a better way?
>
>
I've tried reading the quicktime documentation, but I'm left in awe of
>
the maze of twisty passages, all like. The grues must have carefully
>
hidden a callback function for which I can register, right? Pointers
>
to source code or the desired documentation would be greatly
>
appreciated.
>
Daryn,
You need to setup the callback yourself. Callbacks are explained in the
QuickTime doc. Like you, I didn't know much when I started programming with
QuickTime from Cocoa. Check SimpleVideoOut sample.
Personally, I did write a method in my playback controller like this:
- (void)setupMoviePlayingCompleteCallback:(Movie)theMovie
callbackUPP:(QTCallBackUPP)callbackUPP
{
TimeBase tb = GetMovieTimeBase(theMovie);
OSErr err = noErr;
gQtCallBack = NewCallBack (tb, callBackAtExtremes);
if (gQtCallBack != NULL)
{
err = CallMeWhen (gQtCallBack,
callbackUPP,
NULL, /* refCon */
triggerAtStop, /* flags - call us when stopped */
NULL, /* param2 - don't care */
NULL); /* param3 - don't care */
if (err != noErr)
NSLog(@"error %d while setting up callback", err);
}
}
Then, in my play method, I call it like this:
[self setupMoviePlayingCompleteCallback:[currentMovie QTMovie]
callbackUPP:gMoviePlayingCompleteCallBack];
The 'gMoviePlayingCompleteCallBack' is a global that is initialized like
this in my awakeFromNib:
gMoviePlayingCompleteCallBack = NewQTCallBackUPP(&MyCallBackProc);
MyCallBackProc is as follow:
pascal void MyCallBackProc (QTCallBack cb, long refcon)
{
tellPlaybackControllerMovieIsDone();
[(PlayBackController *)playbackController
restoreMoviePlayCompleteCallBack];
}
That's pretty much it. Like I said, check the SimpleVideoOut sample. Lot of
good stuff in there.
Good luck!
-Laurent.
--
============================================================================
Laurent Daudelin AIM/iChat: LaurentDaudelin <
http://nemesys.dyndns.org>
Logiciels Nemesys Software
mailto:email@hidden
bytesexual /bi:t`sek'shu-*l/ adj.: [rare] Said of hardware, denotes
willingness to compute or pass data in either big-endian or little-endian
format (depending, presumably, on a mode bit somewhere). See also NUXI
problem.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.