avkit的內(nèi)容是關(guān)于基本的視頻和圖片播放;(還有就是view的自定義)
(iOS10 之后的播放視頻控制器)AVPlayerViewController (AVKit)新的視頻的播放器宫静;
例子項(xiàng)目鏈接:
https://github.com/helinyu/test_AVKit
屬性:
@property (nonatomic, strong, nullable) AVPlayer *player;
播放的player
@property (nonatomic) BOOL showsPlaybackControls;
//顯示所有的重復(fù)播放的控件
@property (nonatomic, copy) NSString *videoGravity; //視頻重力
AVLayerVideoGravityResizeAspect斩例、 AVLayerVideoGravityResizeAspectFill 羞延、 AVLayerVideoGravityResize拷淘、AVLayerVideoGravityResizeAspect is default. <AVFoundation/AVAnimation.h> 好像這個(gè)頭文件在watch上面才會(huì)有的撇他;
@property (nonatomic, readonly, getter = isReadyForDisplay) BOOL readyForDisplay;
//準(zhǔn)備顯示
@property (nonatomic, readonly) CGRect videoBounds;
//視頻的大小
@property (nonatomic, readonly, nullable) UIView *contentOverlayView;
//內(nèi)容覆蓋視頻
@property (nonatomic) BOOL allowsPictureInPicturePlayback NS_AVAILABLE_IOS(9_0);
//是否允許PIP
@property (nonatomic) BOOL updatesNowPlayingInfoCenter NS_AVAILABLE_IOS(10_0);
//更新現(xiàn)在播放顯示的信息中心
@property (nonatomic, weak, nullable) id <AVPlayerViewControllerDelegate> delegate NS_AVAILABLE_IOS(9_0);
//代理
requiresLinearPlayback
是否允許跳過(guò)媒體內(nèi)容
contentProposalViewController
內(nèi)容的目標(biāo)視圖控制器
幾個(gè)對(duì)應(yīng)的pip對(duì)應(yīng)的代理方法
AVPlayerViewControllerDelegate 代理類(這幾個(gè)代理方法)
- (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 顯示視頻是通過(guò)里面的一個(gè)vaplayer的屬性(該屬性帶有系統(tǒng)提供的一個(gè)回放的控件)
重點(diǎn): 這個(gè)類是不可以進(jìn)行繼承和重寫里面的方法竹习;
1誊抛、支持airplay
2、(PIP【picture in picture 】)ios 9 之后的內(nèi)容整陌;(應(yīng)該就是一個(gè)縮小化的技術(shù)內(nèi)容),視頻的懸浮顯示拗窃;
http://www.jcodecraeer.com/IOS/2015/0811/3289.html (PIP參考鏈接)
畫(huà)中畫(huà)的效果:
1瞎领、 AVPlayerViewController 這個(gè)控制器就已經(jīng)實(shí)現(xiàn)了畫(huà)中畫(huà)的效果;
2随夸、使用WKWebkit也是有PIP效果的九默;
3、自定義宾毒,通過(guò) AVPictureInPictureController 和 AVPlayerLayer 一起使用驼修;
進(jìn)制畫(huà)中畫(huà)的操作:(手機(jī)上設(shè)置)
設(shè)置 > 通用 > 多任務(wù) > 保持視頻層里設(shè)置
可以直接在storyBoard上拖拽出來(lái),參考鏈接:
http://www.reibang.com/p/41b3ecf3ab0d
诈铛、