6

I have an issue with my AVAudioPlayer in which if it is paused, I cannot get it to play again. Calling [audioPlayer play] after it is paused returns NO rather than the usual YES. Any idea what could have caused this?

Someone else has this same issue as well:

http://www.iphonedevforums.com/forum/sdk-coding-help/750-avaudioplayer-doesnt-start-back-up-after-interruption.html

Boon
  • 40,656
  • 60
  • 209
  • 315

1 Answers1

5

I had this same problem when setting currentTime before invoking the play method. Moving the property set of currentTime to after invoking play method allowed AVAudioPlayer to return YES instead of NO. I'm not sure why this is, hope it helps.

Edit: after further consultation with this issue, calling stop then play seems to work more consistently and thus allows currentTime setting before the play method. You may want to call prepareToPlay just after your stop though to queue it up again for play when you're ready to resume.

iGatiTech
  • 2,306
  • 1
  • 21
  • 45
J.D.
  • 595
  • 1
  • 9
  • 16
  • 1
    Thankyou, I was having the same problem, but using MonoTouch, and your solution fixed it for me :) – NeilDurant Jul 23 '10 at 17:46
  • @NeilDurant : could you pls post any sample code because even im using monotouch and facing the same problem. – sujay Aug 09 '13 at 07:29