3

I am playing audio in my application using audioPlayer.Play()

and it is play correctly.

i can not find when audio finish. i want delegate method when audio finished.

can you please write method when audio finished?

Nimisha Ranipa
  • 8,304
  • 2
  • 14
  • 29
imjaydeep
  • 878
  • 1
  • 11
  • 34

2 Answers2

2

may be it is not possible with audiotoolbox framework, but what you can try is AVAudioPlayer.

just try following after adding:

#import <AVFoundation/AVFoundation.h>

then use delegate method below to handle anything when audio finishes playing:

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
   // Audio finished playing
   //handle anything here
}
Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51
1

set delegate to self

[myAudioPlayer setDelegate:self];

and then implement

    -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
  /*Handle Code here*/
}
gunjot singh
  • 2,578
  • 20
  • 28