Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top