1

I have an application for video streaming. It has ability to make mirroring AirPlay (Apple Tv). Now I'm trying to add Google Chromecast connection. I added button and everything working just I expected. Here is my case: I want user only be able to connect 1 device at the moment. For example if user already conneceted to AirPlay when user tap on Chromecast, I want to disable AirPlay programmatically.

Here's how I checked external playback status:

self.videoPlayer.isExternalPlaybackActive

Here's how I checked is AirPlay connected:

- (BOOL)isAirPlayConnected {
    return self.airPlayButton.isWirelessRouteActive;
}

I know this is how I disabled all external display:

self.videoPlayer.allowsExternalPlayback = NO;
self.videoPlayer.usesExternalPlaybackWhileExternalScreenIsActive = NO;

I already listening: MPVolumeViewWirelessRoutesAvailableDidChangeNotification and MPVolumeViewWirelessRouteActiveDidChangeNotification notifications.

Bu couldn't find solution for programatically disconnect before switching the other.

Any help would be appreciated.

MGY
  • 7,245
  • 5
  • 41
  • 74
  • Try to add an observer to get the airplay event changes something similar to this https://stackoverflow.com/a/35479281/2000162 and manage the logic to connect-disconnect the chromecast – TomCobo Aug 28 '17 at 09:26
  • Thank you, @TomCobo I already manage logic but din't find any solution for programatically disconnect before switching other. – MGY Aug 28 '17 at 09:34
  • From the top of my head I think you can't disconnect AirPlay programatically. Not sure about it. You can allow the allowExternalPlayback in AVplayer. Look at this https://developer.apple.com/documentation/avfoundation/avplayer#//apple_ref/occ/instp/AVPlayer/usesExternalPlaybackWhileExternalScreenIsActive This way you could change allowsExternalPlayback var – TomCobo Aug 28 '17 at 12:47
  • I'm already using "allowsExternalPlayback" like I said. But It's for all external playback I think. Also I'm thinking same with you about disconnecting AirPlay programmatically not possible probably. Event if I could make it, Apple will reject it. But I didn't find any "forbidden" about it yet :) – MGY Aug 29 '17 at 06:35

0 Answers0