AirPlay Implementation in AVPlayer
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
As simple as that. You have implemented AirPlay in your custom control. Please feel to reach me at pratheesh_db@hotmail.com for any help or queries in Swift. Happy coding!!