0

Ok so Iv'e been trying to search for a solution for the past 2 hours but nothing had my problem fixed. Solutions Iv'e tried: - set the Background Modes to ON and check Audio, AirPlay, Picture... - add to info.plist Required background modes and under that App plays audio using airplay

here's my code:

        do {

        audioPlayer = try AVAudioPlayer(contentsOf: destinationUrl!)
        audioPlayer.prepareToPlay()

        let audioSession = AVAudioSession.sharedInstance()
        do{
            try audioSession.setCategory(AVAudioSessionCategoryPlayback)
        }catch{

        }
        print("starting to play...")

        audioPlayer.play()
        state = true
        started = true
        completionHandler()
    } catch let error {
        print(error)
    }

Thanks in advance for anyone trying to help.

Erik17
  • 33
  • 4
  • Duplicate: https://stackoverflow.com/questions/31604629/audio-player-play-in-background-and-should-be-work-with-hardware-mute-switch?rq=1 – El Tomato Dec 02 '17 at 02:21
  • it isn't, what im trying to do is keep playing a song while app enters background... – Erik17 Dec 02 '17 at 09:04

0 Answers0