ajay
ajay

Reputation: 3345

Requesting a call back or notification once avaudioplayer completes it's playback

I am working in audio player module where it takes one audio file and playing. I am using AvAudioPlayer to play my audio file, it's working as expected and I am getting call backs once finished the audio playback. I have implemented looping by numberOfLoops property with negative value so far it's good. In a case I need call back once the current audio finishes playing first time. Is there any possible way to get call back or observer to notify me my audio played first time.

My idea is that we can achieve this by running a timer. What is the best approach?

Generic: Each time completion of audio play back expecting a notification even it has infinite loop also.

Upvotes: 0

Views: 2048

Answers (1)

Swapnil
Swapnil

Reputation: 127

first make numberofloops=0 use this delegate method so this method will call, - (void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) appSoundPlayer successfully: (BOOL) flag

then in that method u can make numberofloops= -1 so that u can get first notification and after loop continues. and [player play]..

and if u write numberofloops= 0 in audioPlayerDidFinishPlaying and play then each time audioPlayerDidFinishPlaying will call like loop..and you can get notification for each..

Upvotes: 4

Related Questions