Apple TV is connected on same WiFi network. AirPlay device is shown as Connected on AirPlay Picker. Video playing but only when mirroring is turned on.
Screens array count is 2 only when mirroring is turned on. Is there a way to display contents on Apple TV without even turning on mirroring.
How do I get Screen count 2 without turning on Mirroring on iOS device.
Here is my code:
func checkForExistingScreenAndInitializeIfPresent() {
    print("\n Total Displays Available:-:- \(UIScreen.screens().count)")        
    if UIScreen.screens().count > 1 {
        // Get the screen object that represents the external display.
        let secondScreen: UIScreen = UIScreen.screens()[1]
        let screenBounds: CGRect = secondScreen.bounds
        self.secondWindow = UIWindow(frame: screenBounds)
        self.secondWindow!.screen = secondScreen
        self.secondWindow!.hidden = false
        let airplayName: String = self.activeAirplayOutputRouteName()
        print("\n External Displays:- \(airplayName) :- Connected")
        print("\n Total Displays Available:- \(UIScreen.screens().count)")
        print("\(airplayName) bounds : \(secondScreen.nativeBounds)")  
    } 
}
func activeAirplayOutputRouteName() -> String {
    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    let currentRoute: AVAudioSessionRouteDescription = appDelegate.audioSession.currentRoute
    for outputPort: AVAudioSessionPortDescription in currentRoute.outputs {
        if (outputPort.portType == AVAudioSessionPortAirPlay) {
            return outputPort.portName
        }
    }
    return ""
}