[英]AVPlayerLayer Vs AVPlayerViewController
I am new to iOS app developing field. 我是iOS应用开发领域的新手。 I am trying to capture video using AVFoundation .
我正在尝试使用AVFoundation捕获视频。 I am successful in this.
我在这方面很成功。 But when I tried to play the video back using MPMoviePlayerController , I got too many issues.
但是,当我尝试使用MPMoviePlayerController播放视频时,出现了太多问题。 So I am trying to play using AVPlayer .
所以我正在尝试使用AVPlayer播放。 But in AVPlayer there are two approaches AVPlayerLayer and AVPlayerViewController .
但是在AVPlayer中 ,有两种方法AVPlayerLayer和AVPlayerViewController 。 I tried searching about those, but I didn't get any particular reason to choose one.
我尝试搜索这些内容,但没有任何特别的理由选择一个。 Can anyone suggest me which is better to use?
谁能建议我使用哪个更好?
AVPlayerViewController
is an all in one solution. AVPlayerViewController
是一个多合一的解决方案。 You setup your AVPlayer
with a video and present the player controller. 您用视频设置
AVPlayer
并显示播放器控制器。 It handles all the playing and has its own controls baked in (I'm sure you've used seen this in other apps). 它处理所有播放,并内置了自己的控件(我敢肯定您曾经在其他应用程序中看到过此控件)。 It is the simplest way to show a video.
这是显示视频的最简单方法。
AVPlayerLayer
is for when you want to add some customization, like adding your own controls or extra views, or not making the video full screen. AVPlayerLayer
适用于您想要添加一些自定义设置的情况,例如添加自己的控件或额外的视图,或者不使视频全屏显示。
AVPlayerViewController
is a handy view controller that needs a player object to be useful. AVPlayerViewController
是一个方便的视图控制器,需要使用播放器对象才有用。 Once it has one, present it as a fullscreen video player. 拥有一个后,将其呈现为全屏视频播放器。
AVPlayerViewController
's view hosts an AVPlayerLayer
for you automatically. AVPlayerViewController
的视图自动为您托管AVPlayerLayer
。
AVPlayerLayer
This special CALayer
subclass can display the playback of a given AVPlayer
object. AVPlayerLayer
这个特殊的CALayer
子类可以显示给定AVPlayer
对象的回放。 Think of it as a monitor: it renders content for the connected AVPlayer
. 可以将其视为监视器:它为连接的
AVPlayer
呈现内容。 It is useful when you want to write a Custom Video View. 当您要编写自定义视频视图时,此功能很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.