0

My app plays videos in WKWebview, and before I play a video, I want to know if Apple TV was previously selected from the attached menu. This is different than detecting if AirPlay or screen mirroring is active as both will evaluate as false prior to a video being played, even if Apple TV is selected.

What's a way to detect this selection in Objective C?

Showing Apple TV selected

egekhter
  • 2,067
  • 2
  • 23
  • 32
  • better check for AVAudioSessionPortAirPlay or read https://stackoverflow.com/questions/13044894/get-name-of-airplay-device-using-avplayer because if AirPlay is selected iOS will stream its audio as well, even without video. – Ol Sen Oct 30 '20 at 04:12
  • This is not reliable, as it only evaluates to true after AVPlayerViewController is presented, not before. – egekhter Oct 30 '20 at 16:23
  • there is not even `AVPlayerViewController` involved. If your app starts up and one of indexed outputs-portType `[AVAudioSession sharedInstance].currentRoute.outputs[index].portType==AVAudioSessionPortAirPlay` then it is selected, unless your iOS or AppleTV is broken. But you possibly wanted to know how to access AirPlay via js from WkWebViews. – Ol Sen Oct 30 '20 at 17:52
  • still not clear what your question is because you presented the iOSystems menu, not something that is bound to any wkwebview here. – Ol Sen Oct 30 '20 at 17:55
  • When AirPlay is selected but not active and you try to play a video element in WKWebView, instead of playing inline, it will display a black screen with text "Playing on AirPlay" and then immediately pauses the video without ever playing it. In this scenario, I'd like to fallback to using the native iOS video player. – egekhter Oct 30 '20 at 19:01
  • same as this scenario. User watches video, decides to switch to Airplay, AppleTV needs to wake up from sleep, the video on display is black + ongoing on success "Playing on AirPlay" when sleep mode has ended but the stream is not running yet. Just saying AirPlay is also a Bonjour port socket protocol (_airplay._tcp). So your question does not belong to iOS first hand. – Ol Sen Oct 30 '20 at 19:19

0 Answers0