avkit的内容是关于基本的视频和图片播放;(还有就是view的自定义)
(iOS10 之后的播放视频控制器)AVPlayerViewController (AVKit)新的视频的播放器;
例子项目链接:
https://github.com/helinyu/test_AVKit
属性:
@property (nonatomic, strong, nullable) AVPlayer *player;
播放的player
@property (nonatomic) BOOL showsPlaybackControls;
//显示所有的重复播放的控件
@property (nonatomic, copy) NSString *videoGravity; //视频重力
AVLayerVideoGravityResizeAspect、 AVLayerVideoGravityResizeAspectFill 、 AVLayerVideoGravityResize、AVLayerVideoGravityResizeAspect is default. <AVFoundation/AVAnimation.h> 好像这个头文件在watch上面才会有的;
@property (nonatomic, readonly, getter = isReadyForDisplay) BOOL readyForDisplay;
//准备显示
@property (nonatomic, readonly) CGRect videoBounds;
//视频的大小
@property (nonatomic, readonly, nullable) UIView *contentOverlayView;
//内容覆盖视频
@property (nonatomic) BOOL allowsPictureInPicturePlayback NS_AVAILABLE_IOS(9_0);
//是否允许PIP
@property (nonatomic) BOOL updatesNowPlayingInfoCenter NS_AVAILABLE_IOS(10_0);
//更新现在播放显示的信息中心
@property (nonatomic, weak, nullable) id <AVPlayerViewControllerDelegate> delegate NS_AVAILABLE_IOS(9_0);
//代理
requiresLinearPlayback
是否允许跳过媒体内容
contentProposalViewController
内容的目标视图控制器
几个对应的pip对应的代理方法
AVPlayerViewControllerDelegate 代理类(这几个代理方法)
- (void)playerViewControllerWillStartPictureInPicture:(AVPlayerViewController *)playerViewController;
- (void)playerViewControllerDidStartPictureInPicture:(AVPlayerViewController *)playerViewController;
- (void)playerViewController:(AVPlayerViewController *)playerViewController failedToStartPictureInPictureWithError:(NSError *)error;
- (void)playerViewControllerWillStopPictureInPicture:(AVPlayerViewController *)playerViewController;
- (void)playerViewControllerDidStopPictureInPicture:(AVPlayerViewController *)playerViewController;
- (BOOL)playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart:(AVPlayerViewController *)playerViewController;
- (void)playerViewController:(AVPlayerViewController *)playerViewController restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:(void (^)(BOOL restored))completionHandler;
PS概览:
AVPlayerViewController 显示视频是通过里面的一个vaplayer的属性(该属性带有系统提供的一个回放的控件)
重点: 这个类是不可以进行继承和重写里面的方法;
1、支持airplay
2、(PIP【picture in picture 】)ios 9 之后的内容;(应该就是一个缩小化的技术内容),视频的悬浮显示;
http://www.jcodecraeer.com/IOS/2015/0811/3289.html (PIP参考链接)
画中画的效果:
1、 AVPlayerViewController 这个控制器就已经实现了画中画的效果;
2、使用WKWebkit也是有PIP效果的;
3、自定义,通过 AVPictureInPictureController 和 AVPlayerLayer 一起使用;
进制画中画的操作:(手机上设置)
设置 > 通用 > 多任务 > 保持视频层里设置
可以直接在storyBoard上拖拽出来,参考链接:
http://www.jianshu.com/p/41b3ecf3ab0d
、