Re: QTKit quickie
Re: QTKit quickie
- Subject: Re: QTKit quickie
- From: Matt Neuburg <email@hidden>
- Date: Thu, 07 Jul 2005 11:43:26 -0700
On Wed, 6 Jul 2005 10:50:05 -0700, Tim Monroe <email@hidden> said:
>So my previous suspicion was right. In this line:
>
>> mov = [QTMovie movieWithFile:s error:nil];
>
>you are creating an autoreleased object. Once you reenter the run loop,
>it's disposed of. The reason your code works when you assign the movie
>to a movie view is that the movie view retains the QTMovie object. And
>the retained QTMovie gets idled through the normal idling mechanism
>built into QTMovie, hence the movie plays.
>
>You just need to change your code to do this:
>
>> QTMovie* mov;
>> mov = [[QTMovie alloc] initWithFile:s error:nil];
>> [mov setVolume: whatever];
>> [mov play];
>
>which works as expected.
Thanks - that's just what I'll do! Ironically, after testing I was going to
retain "mov" in any case (loading the sound file just once at app launch).
This makes perfect sense given the asynchronous playing of sounds/movies and
the nature of the run loop, and I understand now; but my mistake does
perhaps suggest that the docs could do a bit more to warn the user about the
potential pitfalls of the QTMovie convenience class methods. (I notice that
NSSound and NSMovie have no such methods, with the result that one is more
conscious of deallocation issues.)
Thanks again - m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden