how to pause/resume audio when iphone is locked/unlocked
<p>Here's what currently happens in my app:</p>

<p>Locking: iPhone Lock Button Pressed -> Audio Paused<br />
Unlocking: iPhoneUnlocked Button Pressed -> Audio Resumed -> Slide to Unlock -> App Appears</p>

<p>I want the Unlocking sequence to be:</p>

<p>Unlocking: iPhoneUnlock Button Pressed -> Slide to Unlock -> Audio Resumed -> App Appears</p>

<p>I am using OS 2.2.1 and AVFoundation Framework, and here's what I have already tried:</p>

<ul>
<li><p>I tried to use applicationWillResignActive and applicationDidBecomeActive callbacks of the AppDelegate, it doesn't work. Although applicationDidBecomeActive is called at the correct time (i.e. when user has slided to unlock the device), the audio gets resumed as soon as unlock button is pressed (I guess it is because of the audio sessions), so I tried:</p></li>
<li><p>I implemented audioPlayerBeginInterruption and audioPlayerEndInterruption selectors of the AVAudioPlayerDelegate, it looks like these methods never get called (I have placed log calls). I'm sure I am setting the delegate properly since audioPlayerDidFinishPlaying is correctly called when an audio file has finished playing.</p></li>
</ul>

<p>Any ideas? :-) </p>

<p>P.S: I am testing on device if that wasn't obvious</p>
