How to play video with AVPlayerViewController (AVKit) in xamarin iOS

前端 未结 2 1709
傲寒
傲寒 2021-01-03 11:59

How to play a video using AVPlayerLayer, and AVPlayerViewControler in xamarin iOS?

playerItem = new AVPlayerItem(new NSUrl(\"https://clips.vorwaerts-gmbh.de/         


        
2条回答
  •  囚心锁ツ
    2021-01-03 12:25

    AVPlayer avp;
    AVPlayerViewController avpvc;
    
    
    var url = NSUrl.FromString(yourURL);
                avp = new AVPlayer(url);
                avpvc = new AVPlayerViewController();
                avpvc.Player = avp;
                AddChildViewController(avpvc);
                View.AddSubview(avpvc.View);
                avpvc.View.Frame = View.Frame;
                avpvc.ShowsPlaybackControls = true;
                avp.Play();
    

    This is all done in viewDidLoad and its working fine now.

提交回复
热议问题