How do you make audio play when iphone is locked?

Discussion in 'iOS Programming' started by mguniverse, Apr 9, 2010.

  1. mguniverse macrumors newbie

    Joined:
    Jan 24, 2010
    #1
    This question also relates to ipad, but i assume it's the same. Does anyone know what I need to add to my app if I want audio to continue playing when the device is locked? This would be very helpful, so answer as soon as possible.

    Also I don't mean background audio from iphone 4.0, just how to make it play when the iphone is LOCKED.

    I know the pandora app does this.
     
  2. mbsaeger macrumors 6502

    mbsaeger

    Joined:
    Jun 18, 2009
    #2
    Just make sure you're using the right Audio Session Category. By default AVAudioSessionCategorySoloAmbient will be used. You want to use AVAudioSessionCategoryPlayback so the audio will not fade behind the lock screen.
     
  3. mguniverse thread starter macrumors newbie

    Joined:
    Jan 24, 2010
    #3
    How do I do this?
     
  4. mbsaeger macrumors 6502

    mbsaeger

    Joined:
    Jun 18, 2009
    #4
    Just change the one to another. If you are already using audio, you should have this. Check out Apples avTouch sample in the dev center.
     

Share This Page