Hey all, today we are going to see a simple and straightforward implementation of AirPlay when using custom player controls as it is totally free with the AVPlayerViewController
To implement AirPlay routing we use AVRoutePickerView class. AVRoutePickerView is a subclass of UIView that displays control for picking playback routes.
- Enable AirPlay in the Background Mode under targets -> Signing & Capabilities
2. In order to make AVRoutePickerView detect external routes, we have to enable the allowsExternalPlayback property of the AVPlayer to true
3. Add the AVRoutePickerView instance to the view. AVRoutePickerView provides the system AirPlay icon.
routePickerViewWillBeginPresentingRoutes, routePickerViewDidEndPresentingRoutes are the delegates provided by the AVRoutePickerView