Apple TV подключен к той же сети Wi-Fi. Устройство AirPlay отображается как «Подключено» в средстве выбора AirPlay. Видео воспроизводится, но только при включенном зеркалировании.
Количество экранов в массиве равно 2 только при включенном зеркалировании. Есть ли способ отображать содержимое на Apple TV, даже не включая зеркалирование.
Как получить количество экранов 2 без включения зеркального отображения на устройстве iOS.
Вот мой код:
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 ""
}