Integrating AirPlay to iOS app in Swift
Asked Answered
B

1

9

I want to cast a radio stream through AirPlay (to an AppleTV). I've researched a lot related to this topic, but I found the documentation really poor.

This is the Apple documentation for AirPlay 2: https://developer.apple.com/documentation/avfoundation/airplay_2/getting_airplay_2_into_your_app

I found out that AVRoutePickerView is only available after iOS 11. Below iOS 11, MPVolumeView needs to be used.

I've checked the iOS version, integrated these classes, the cast is working, buy not how I want it

A black screen appears on the TV while playing and I can't control the volume of the cast.

Can anyone show me how to integrate AirPlay into an iOS app simple and clearly? Any help would be appreciated.

Bozeman answered 20/2, 2018 at 15:10 Comment(0)
B
7

The problem was I set on my AVPlayer object the allowsExternalPlayback to true. This property's "ancestor" in earlier versions of iOS (until 6.0), was more meaningful with the name of: allowsAirPlayVideo.

SO if you call this allowsExternalPlayback = false on your player, the black screen disappears and you can also control the volume of the radio cast.

Bozeman answered 19/6, 2018 at 7:52 Comment(1)
No, but as far as I remember you have to set this property to false on your player instance: developer.apple.com/documentation/avfoundation/avplayer/…Bozeman

© 2022 - 2024 — McMap. All rights reserved.