如何在 xamarin iOS 中使用 AVPlayerLayer 和 AVPlayerViewControler 播放视频?
playerItem = new AVPlayerItem(new NSUrl("https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"));
player = new AVPlayer(playerItem);
AVcontroller.Player = player;
AVcontroller.View.Layer.Frame = this.View.Bounds;
this.View.AddSubview(AVcontroller.View);
//AVcontroller.SetFullscreen(true, true);
AVcontroller.Player.Play();
最佳答案
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();
这一切都在 viewDidLoad 中完成,现在工作正常。
关于c# - 如何在 xamarin iOS 中使用 AVPlayerViewController (AVKit) 播放视频,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38865797/