Re: [NSSound isPlaying] fails to indicate sound termination in Lion
Re: [NSSound isPlaying] fails to indicate sound termination in Lion
- Subject: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
- From: Ken Thomases <email@hidden>
- Date: Sun, 22 Jul 2012 20:03:47 -0500
On Jul 22, 2012, at 7:43 PM, Jay Reynolds Freeman wrote:
> The "sleep" was only for instrumentation; without the sleep and the NSLog, the code exhibits the problem described. And [NSSound play] is supposed to run asynchronously ...
You didn't pay attention to what Fritz wrote. You need to allow flow of execution to leave your code and return to the framework, so that the framework can run the main event loop. In all probability, NSSound needs to receive an external notification or event to realize that the sound has finished playing. It probably receives that notification/event via a run-loop source scheduled on the main thread's run loop.
There's no good reason for you to loop, polling for the sound's completion. Use the asynchronously-delivered delegate method, as Fritz suggested.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden