2

This code snippet makes the other audio (aka iPod) to stop:

func setSessionPlayer() {

    var audioSessionError: NSError?
    let audioSession = AVAudioSession.sharedInstance()

    audioSession.setActive(true, error: nil)

    if audioSession.setCategory(AVAudioSessionCategoryPlayback, withOptions:AVAudioSessionCategoryOptions.MixWithOthers,
        error: &audioSessionError) {
            println("Successfully set the audio session")
    } else {
        println("Could not set the audio session")
    }

}

What am I missing?

Stéphane de Luca
  • 11,714
  • 8
  • 50
  • 75

1 Answers1

3

I think it's because you're setting the audioSession.active before it's configured to MixWithOthers. Move audioSession.setActive below the if block like so:

if audioSession.setCategory(AVAudioSessionCategoryPlayback, withOptions:AVAudioSessionCategoryOptions.MixWithOthers,
    error: &audioSessionError) {
        println("Successfully set the audio session")
} else {
    println("Could not set the audio session")
}

audioSession.setActive(true, error: nil)
Ron Fessler
  • 2,691
  • 1
  • 16
  • 22