• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: QTKit quickie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Sample Cocoa code to show how to launch a doc by sliding its icon into appl icon
  • Next by Date: Re: Smart Group Question
  • Previous by thread: Re: QTKit quickie
  • Next by thread: NSTreeController and Core Data.
  • Index(es):
    • Date
    • Thread