title: how to start to play music in locked screen in iPhone
body: <p>I am using <code>UILocalNotification</code> to alert the user if app not running and <code>MPMusicPlayerController</code> to play iPod music and <code>MPMoviePlayerController</code> to play radio stream url.</p>
  
  <p>According to Apple doc:
   if iphone is locked and device receives local notification then it will play 30 second sound and when user  slides the slider then it will take app in foreground and two scenarios take place</p>
  
  <ol>
  <li><p>If App not running then calls method </p>
  
  <p><code>(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions</code></p></li>
  <li><p>If App already running then calls method -</p>
  
  <p><code>(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notify</code></p></li>
  </ol>
  
  <p>and i can perform my task in these methods.</p>
  
  <p>Problem :
  I need my application to be able to play my sound (it may be iPod music or stream url but not local notification sound for 30 sec) when the iPhone is locked and local notification  received and app is running in foreground.</p>
  
  <p>Reference App :
  "Alarm Clock HD" and other apps also available in app store are working fine in this way but these are not able to play alarm when app is running in background (i could not understand why???)</p>
  
  <p>I also tried  <a href="http://blog.marcopeluso.com/2009/08/23/how-to-prevent-iphone-from-deep-sleeping/" rel="nofollow">how-to-prevent-iphone-from-deep-sleeping</a> :</p>
  
  <p>which prevent the iPhone from deep sleep by playing silent music periodically but how to notify app that notification has received so start to play "actual music" ? And how to start to play new music?</p>