gpt4 book ai didi

c# - 如何在 xamarin iOS 中使用 AVPlayerViewController (AVKit) 播放视频

转载 作者:行者123 更新时间:2023-11-30 19:15:25 28 4
gpt4 key购买 nike

如何在 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com