AVRoutePicker in tvOS

Does anyone know how to implement AVRoutePickerView in a tvOS app similarly to how it is implemented in Apple's Music App for tvOS?


I would like to give the option to select a bluetooth or AirPlay route via button in my app in the same way that the "now playing" view in the Music App.

Replies

By doing the following you can add a button (of type 'system') with the airPlay icon in your view:


let myRoutePickerView = AVRoutePickerView()
myRoutePickerView.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
self.view.addSubview(myRoutePickerView)

When pressed, it will ivoke the natvie UI for selecting the different route options that your user may have available.
But if you're looking a way of customizing that default button like in the Music app on TVOS, that would require more effort from your side:


myRoutePickerView.routePickerButtonStyle = .custom

By setting the type of that button to 'custom', it will allow you to customize it and do things like the Music app does (eg. circle button, translucent background, etc.)