I want to create an application screen mirror the whole screen to smart TV
I have found some apps on the market that do the trick This is a sample https://apps.apple.com/ec/app/gomirror-screen-mirroring/id1484792219
I paid and tried the trial version, then tried to mirror the iPhone screen with a smart Samsung TV, and it worked.
Also I tried something else, I used Reflector Mac application (Desktop app) and used this code
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let routePickerView = AVRoutePickerView(frame: CGRect(x: 0.0, y: 30.0, width: 30.0, height: 30.0))
routePickerView.backgroundColor = UIColor.lightGray
self.view.addSubview(routePickerView)
let avAsset = AVAsset(url: URL(string: "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4")!)
let avPlayerItem = AVPlayerItem(asset: avAsset)
let avPlayer = AVPlayer(playerItem: avPlayerItem)
let avPlayerLayer = AVPlayerLayer(player: avPlayer)
avPlayerLayer.frame = CGRect(x: 0.0, y: 40.0, width: self.view.frame.size.width, height: self.view.frame.size.height - 40.0)
self.view.layer.addSublayer(avPlayerLayer)
avPlayer.seek(to: CMTime.zero)
avPlayer.play()
}
this code show a player and add the ability to mirror ONLY the player into Mac screen, But I just was playing around, What I really want to screen mirror the full screen to a Smart TV.
Edit 1: I found that some applications are recording the screen of the Mobile phone and send it as a video for the TV, and this make some delay between the action on the iPhone and the preview on the TV, so if any one knows how to that programmatically that would be great.