简体   繁体   中英

AVPlayerLayer Vs AVPlayerViewController

I am new to iOS app developing field. I am trying to capture video using AVFoundation . I am successful in this. But when I tried to play the video back using MPMoviePlayerController , I got too many issues. So I am trying to play using AVPlayer . But in AVPlayer there are two approaches AVPlayerLayer and 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. You setup your AVPlayer with a video and present the player controller. 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.

在此处输入图片说明

AVPlayerViewController is a handy view controller that needs a player object to be useful. Once it has one, present it as a fullscreen video player. AVPlayerViewController 's view hosts an AVPlayerLayer for you automatically.

AVPlayerLayer This special CALayer subclass can display the playback of a given AVPlayer object. Think of it as a monitor: it renders content for the connected AVPlayer . It is useful when you want to write a Custom Video View.

Read more here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM