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.