Question

I'm using a series of AVAudioPlayers concurrent with the main thread using dispatch_async. Before playing each one I must query, whether it is playing using its isPlaying method.

I am generally unfamiliar with multithreading, so how would I go about calling the isPlaying method on the thread that the AVAudioPlayer is currently working on?

Was it helpful?

Solution

You can access the property playing directly on main thread because the operation is read, so it is safe I think :)

But you can't use it to judge if playback has completed as document says : Important: Do not poll this property to determine when playback has completed, instead implement the specified delegate method

You should use delegate and implement the method - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag, if the method is called, it means the player stop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top