'Airplay support iOS

I'am trying to add airplay for my audio app. Here is my code

let buttonView  = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
let routerPickerView =  AVRoutePickerView(frame: buttonView.bounds)
routerPickerView.tintColor = UIColor.white
routerPickerView.activeTintColor = UIColor.white
buttonView.addSubview(routerPickerView)
self.btnsStack.addArrangedSubview(buttonView)

This works well with my Mac, but when I try to play it with my Samsung Smart TV, there is a loader keeps on spinning. I tried connecting my TV with other apps like Spotify and it works.



Solution 1:[1]

Found my solution, so for casting airplay with smart tv one line of code is must

    player?.allowsExternalPlayback = false

player is your AVPlayer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sagar Thukral