What I have tried?
- UIScreen.screens.count > 1
Ans : Always getting one even though my app is currently Airplay(ing) on my Macbook
- Setting configuration of WKWebView
mediaPlaybackAllowsAirPlay = false
allowsAirPlayForMediaPlayback = false
Although the airplay button is not present in the player controls but one can still caste using the control panel airplay button by swipping the screen from above.
- Tried this method used widely to detect Airplay but it only detects in case of screen mirroring no callbacks for Airplay.
func isAirplayOn() -> Bool {
let audioSession = AVAudioSession.sharedInstance()
let currentRoute = audioSession.currentRoute
for outputPort in currentRoute.outputs {
if outputPort.portType == AVAudioSession.Port.airPlay {
return true
}
}
return false
}
So to my vain this also does not work. Let me know how to either detect airplay or disable it on WKWebView's Audio/Video Player. Any help will be highly appreciated.