詳細(xì)介紹一下ZFPlayer 3.0的用法,如果你有什么問(wèn)題或者建議可聯(lián)系我。在3.0之前版本使用ZFPlayer,是不是在煩惱播放器SDK自定義、控制層自定義等問(wèn)題。作者公司多個(gè)項(xiàng)目分別使用不同播放器SDK以及每個(gè)項(xiàng)目控制層都不一樣,但是為了統(tǒng)一管理、統(tǒng)一調(diào)用,我特意寫(xiě)了這個(gè)播放器殼子。播放器SDK只要遵守ZFPlayerMediaPlayback協(xié)議,控制層只要遵守ZFPlayerMediaControl協(xié)議,可以實(shí)現(xiàn)自定義播放器和控制層。
目前支持的功能如下:
- 普通模式的播放,類(lèi)似于騰訊視頻、愛(ài)奇藝等APP;
- 列表普通模式的播放,包括手動(dòng)點(diǎn)擊播放、滑動(dòng)到屏幕中間自動(dòng)播放,wifi網(wǎng)絡(luò)智能播放等等;
- 列表的亮暗模式播放,類(lèi)似于微博、UC瀏覽器視頻列表等APP;
- 列表視頻滑出屏幕后停止播放、滑出屏幕后小窗播放;
- 優(yōu)雅的全屏,支持橫屏和豎屏全屏模式;
播放器的主要類(lèi)為ZFPlayerController,具體API請(qǐng)看下邊這張圖吧,后邊我也會(huì)詳細(xì)介紹。在之前版本收到好多開(kāi)發(fā)朋友的Issues建議也好bug也好,ZFPlayer也是致力于解決這些問(wèn)題和滿(mǎn)足各位的建議。

ZFPlayer思維導(dǎo)圖
ZFPlayerController(播放器的主要類(lèi))
初始化方式:
/// 普通播放的初始化
+ (instancetype)playerWithPlayerManager:(id<ZFPlayerMediaPlayback>)playerManager containerView:(UIView *)containerView;
/// 普通播放的初始化
- (instancetype)initWithPlayerManager:(id<ZFPlayerMediaPlayback>)playerManager containerView:(UIView *)containerView;
/// UITableView、UICollectionView播放的初始化
+ (instancetype)playerWithScrollView:(UIScrollView *)scrollView playerManager:(id<ZFPlayerMediaPlayback>)playerManager containerViewTag:(NSInteger)containerViewTag;
/// UITableView、UICollectionView播放的初始化
- (instancetype)initWithScrollView:(UIScrollView *)scrollView playerManager:(id<ZFPlayerMediaPlayback>)playerManager containerViewTag:(NSInteger)containerViewTag;
/// UIScrollView播放的初始化
+ (instancetype)playerWithScrollView:(UIScrollView *)scrollView playerManager:(id<ZFPlayerMediaPlayback>)playerManager containerView:(UIView *)containerView;
/// UIScrollView播放的初始化
- (instancetype)initWithScrollView:(UIScrollView *)scrollView playerManager:(id<ZFPlayerMediaPlayback>)playerManager containerView:(UIView *)containerView;
屬性
/// 初始化時(shí)傳遞的容器視圖,用來(lái)顯示播放器view,和播放器view同等大小
@property (nonatomic, strong) UIView *containerView;
/// 初始化時(shí)傳遞的播放器manager,必須遵守`ZFPlayerMediaPlayback`協(xié)議
@property (nonatomic, strong) id<ZFPlayerMediaPlayback> currentPlayerManager;
/// 此屬性是設(shè)置顯示的控制層,自定義UIView遵守`ZFPlayerMediaControl`協(xié)議,實(shí)現(xiàn)相關(guān)協(xié)議就可以滿(mǎn)足自定義控制層的目的。
@property (nonatomic, strong) UIView<ZFPlayerMediaControl> *controlView;
/// 通知的管理類(lèi)
@property (nonatomic, strong, readonly) ZFPlayerNotification *notification;
/// 容器的類(lèi)型(cell和普通View)
@property (nonatomic, assign, readonly) ZFPlayerContainerType containerType;
/// 播放器小窗的容器View
@property (nonatomic, strong, readonly) ZFFloatView *smallFloatView;
/// 播放器小窗是否正在顯示
@property (nonatomic, assign, readonly) BOOL isSmallFloatViewShow;
ZFPlayerController (ZFPlayerTimeControl)
/// 當(dāng)前播放視頻的時(shí)間
@property (nonatomic, readonly) NSTimeInterval currentTime;
/// 當(dāng)前播放視頻總時(shí)間
@property (nonatomic, readonly) NSTimeInterval totalTime;
/// 當(dāng)前播放視頻緩沖時(shí)間
@property (nonatomic, readonly) NSTimeInterval bufferTime;
/// 根據(jù)播放的時(shí)間和總時(shí)間,計(jì)算出當(dāng)前播放的進(jìn)度,取值范圍0...1
@property (nonatomic, readonly) float progress;
/// 根據(jù)播放緩沖時(shí)間和總時(shí)間,計(jì)算出當(dāng)前緩沖的進(jìn)度,取值范圍0...1
@property (nonatomic, readonly) float bufferProgress;
/// 調(diào)節(jié)播放進(jìn)度
- (void)seekToTime:(NSTimeInterval)time completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;
ZFPlayerController (ZFPlayerPlaybackControl)
/// 0...1.0,調(diào)節(jié)系統(tǒng)的聲音,要是調(diào)節(jié)播放器聲音可以使用播放器管理類(lèi)設(shè)置
@property (nonatomic) float volume;
/// 系統(tǒng)靜音,要是調(diào)節(jié)播放器靜音可以使用播放器管理類(lèi)設(shè)置
@property (nonatomic, getter=isMuted) BOOL muted;
// 0...1.0, 系統(tǒng)屏幕亮度
@property (nonatomic) float brightness;
/// 移動(dòng)網(wǎng)絡(luò)下自動(dòng)播放, default is NO.
@property (nonatomic, getter=isWWANAutoPlay) BOOL WWANAutoPlay;
/// 當(dāng)前播放的下標(biāo),只適用于設(shè)置了`assetURLs`
@property (nonatomic) NSInteger currentPlayIndex;
/// 在 `assetURLs`中是否是最后一個(gè)
@property (nonatomic, readonly) BOOL isLastAssetURL;
/// 在 `assetURLs`中是否是第一個(gè)
@property (nonatomic, readonly) BOOL isFirstAssetURL;
/// 當(dāng)退到后臺(tái)后是否暫停播放,前提是支持后臺(tái)播放器模式,default is YES.
@property (nonatomic) BOOL pauseWhenAppResignActive;
/// 當(dāng)播放器在玩播放時(shí),它會(huì)被一些事件暫停,而不是用戶(hù)點(diǎn)擊暫停。
/// 例如,應(yīng)用程序進(jìn)入后臺(tái)或者push到另一個(gè)視圖控制器
@property (nonatomic, getter=isPauseByEvent) BOOL pauseByEvent;
/// 當(dāng)前播放器控制器消失,而不是dealloc
@property (nonatomic, getter=isViewControllerDisappear) BOOL viewControllerDisappear;
/// 自定義AVAudioSession, default is NO.
@property (nonatomic, assign) BOOL customAudioSession;
/// 當(dāng)播放器Prepare時(shí)候調(diào)用
@property (nonatomic, copy, nullable) void(^playerPrepareToPlay)(id<ZFPlayerMediaPlayback> asset, NSURL *assetURL);
///當(dāng)播放器準(zhǔn)備開(kāi)始播放時(shí)候調(diào)用
@property (nonatomic, copy, nullable) void(^playerReadyToPlay)(id<ZFPlayerMediaPlayback> asset, NSURL *assetURL);
/// 當(dāng)播放進(jìn)度改變時(shí)候調(diào)用.
@property (nonatomic, copy, nullable) void(^playerPlayTimeChanged)(id<ZFPlayerMediaPlayback> asset, NSTimeInterval currentTime, NSTimeInterval duration);
/// 當(dāng)緩沖進(jìn)度改變時(shí)候調(diào)用
@property (nonatomic, copy, nullable) void(^playerBufferTimeChanged)(id<ZFPlayerMediaPlayback> asset, NSTimeInterval bufferTime);
/// 當(dāng)播放狀態(tài)改變時(shí)候調(diào)用
@property (nonatomic, copy, nullable) void(^playerPlayStateChanged)(id<ZFPlayerMediaPlayback> asset, ZFPlayerPlaybackState playState);
/// 當(dāng)加載狀態(tài)改變時(shí)候調(diào)用.
@property (nonatomic, copy, nullable) void(^playerLoadStateChanged)(id<ZFPlayerMediaPlayback> asset, ZFPlayerLoadState loadState);
/// 當(dāng)播放失敗時(shí)候調(diào)用.
@property (nonatomic, copy, nullable) void(^playerPlayFailed)(id<ZFPlayerMediaPlayback> asset, id error);
/// 當(dāng)播放狀態(tài)完成時(shí)候調(diào)用.
@property (nonatomic, copy, nullable) void(^playerDidToEnd)(id<ZFPlayerMediaPlayback> asset);
// 當(dāng)播放器view的尺寸改變時(shí)候調(diào)用.
@property (nonatomic, copy, nullable) void(^presentationSizeChanged)(id<ZFPlayerMediaPlayback> asset, CGSize size);
/// 播放下一個(gè),只適用于設(shè)置了`assetURLs`
- (void)playTheNext;
/// 播放上一個(gè),只適用于設(shè)置了`assetURLs`
- (void)playThePrevious;
/// 播放某一個(gè),只適用于設(shè)置了`assetURLs`
- (void)playTheIndex:(NSInteger)index;
/// 停止播放,并且把播放器view和相關(guān)通知移除
- (void)stop;
/// 切換當(dāng)前的PlayerManager,適用場(chǎng)景:播放某一個(gè)視頻時(shí)候使用特定的播放器管理類(lèi)
- (void)replaceCurrentPlayerManager:(id<ZFPlayerMediaPlayback>)manager;
/**
添加播放器view到cell上
*/
- (void)addPlayerViewToCell;
/**
添加播放器view到容器view上.
*/
- (void)addPlayerViewToContainerView:(UIView *)containerView;
/**
添加播放器到主window上.
*/
- (void)addPlayerViewToKeyWindow;
/**
停止當(dāng)前在view上的播放并移除播放器view.
*/
- (void)stopCurrentPlayingView;
/**
停止當(dāng)前在cell上的播放并移除播放器view.
*/
- (void)stopCurrentPlayingCell;
ZFPlayerController (ZFPlayerOrientationRotation)
/// 屏幕旋轉(zhuǎn)管理類(lèi)
@property (nonatomic, readonly) ZFOrientationObserver *orientationObserver;
///是否支持自動(dòng)屏幕旋轉(zhuǎn)。
/// iOS8.1~iOS8.3的值為YES,其他iOS版本的值為NO。
///這個(gè)屬性用于UIViewController ' shouldAutorotate '方法的返回值。
@property (nonatomic, readonly) BOOL shouldAutorotate;
///是否允許視頻方向旋轉(zhuǎn)。
///默認(rèn)值是YES。
@property (nonatomic) BOOL allowOrentitaionRotation;
/// 是否是全屏狀態(tài),當(dāng)ZFFullScreenMode == ZFFullScreenModeLandscape,當(dāng)currentOrientation是LandscapeLeft或者LandscapeRight,這個(gè)值是YES
/// 當(dāng)ZFFullScreenMode == ZFFullScreenModePortrait,當(dāng)視頻全屏后,這個(gè)值是YES
@property (nonatomic, readonly) BOOL isFullScreen;
/// 鎖定當(dāng)前的屏幕方向,目的是禁止設(shè)備自動(dòng)旋轉(zhuǎn)
@property (nonatomic, getter=isLockedScreen) BOOL lockedScreen;
/// 隱藏系統(tǒng)的狀態(tài)欄
@property (nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden;
/// 使用設(shè)備方向旋轉(zhuǎn)屏幕, default NO.
@property (nonatomic, assign) BOOL forceDeviceOrientation;
/// 播放器view當(dāng)前方向
@property (nonatomic, readonly) UIInterfaceOrientation currentOrientation;
/// 當(dāng)即將全屏?xí)r候會(huì)調(diào)用
@property (nonatomic, copy, nullable) void(^orientationWillChange)(ZFPlayerController *player, BOOL isFullScreen);
/// 當(dāng)已經(jīng)全屏?xí)r候會(huì)調(diào)用
@property (nonatomic, copy, nullable) void(^orientationDidChanged)(ZFPlayerController *player, BOOL isFullScreen);
/// 添加設(shè)備方向的監(jiān)聽(tīng)
- (void)addDeviceOrientationObserver;
/// 移除設(shè)備方向的監(jiān)聽(tīng)
- (void)removeDeviceOrientationObserver;
/// 當(dāng) ZFFullScreenMode == ZFFullScreenModeLandscape使用此API設(shè)置全屏切換
- (void)enterLandscapeFullScreen:(UIInterfaceOrientation)orientation animated:(BOOL)animated;
/// 當(dāng) ZFFullScreenMode == ZFFullScreenModePortrait使用此API設(shè)置全屏切換
- (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated;
/// 內(nèi)部根據(jù)ZFFullScreenMode的值來(lái)設(shè)置全屏切換
- (void)enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated;
ZFPlayerController (ZFPlayerViewGesture)
/// 手勢(shì)的管理類(lèi)
@property (nonatomic, readonly) ZFPlayerGestureControl *gestureControl;
/// 禁用哪些手勢(shì),默認(rèn)支持單擊、雙擊、滑動(dòng)、縮放手勢(shì)
@property (nonatomic, assign) ZFPlayerDisableGestureTypes disableGestureTypes;
///不支持的平移手勢(shì)移動(dòng)方向
@property (nonatomic) ZFPlayerDisablePanMovingDirection disablePanMovingDirection;
ZFPlayerController (ZFPlayerScrollView)
/// 初始化時(shí)候設(shè)置的scrollView
@property (nonatomic, readonly, nullable) UIScrollView *scrollView;
/// 只適用于列表播放時(shí)候是否自動(dòng)播放,default is YES.
@property (nonatomic) BOOL shouldAutoPlay;
/// 移動(dòng)網(wǎng)絡(luò)自動(dòng)播放,只有當(dāng)“shouldAutoPlay”為YES時(shí)才支持,默認(rèn)為NO
@property (nonatomic, getter=isWWANAutoPlay) BOOL WWANAutoPlay;
/// 當(dāng)前播放的indexPath
@property (nonatomic, nullable) NSIndexPath *playingIndexPath;
/// 初始化時(shí)候設(shè)置的containerViewTag,根據(jù)此tag在cell上找到播放器view顯示的位置
@property (nonatomic) NSInteger containerViewTag;
/// 滑出屏幕后是否停止播放,如果設(shè)置為NO,滑出屏幕后則會(huì)小窗播放,defalut is YES.
@property (nonatomic) BOOL stopWhileNotVisible;
/**
當(dāng)前播放器滾動(dòng)滑出屏幕的百分比。
當(dāng)`stopWhileNotVisible`為YES時(shí)使用的屬性,停止當(dāng)前正在播放的播放器。
當(dāng)`stopWhileNotVisible`為NO時(shí)使用的屬性,當(dāng)前正在播放的播放器添加到小容器視圖。
范圍是0.0~1.0,defalut是0.5。
0.0是player將會(huì)消失。
1.0是player消失了。
*/
@property (nonatomic) CGFloat playerDisapperaPercent;
/**
當(dāng)前播放器滾動(dòng)到屏幕百分比來(lái)播放視頻。
范圍是0.0~1.0,defalut是0.0。
0.0是玩家將會(huì)出現(xiàn)。
1.0是播放器確實(shí)出現(xiàn)了。
*/
@property (nonatomic) CGFloat playerApperaPercent;
/// 如果列表播放時(shí)候有多個(gè)區(qū),使用此API
@property (nonatomic, copy, nullable) NSArray <NSArray <NSURL *>*>*sectionAssetURLs;
/**
播放url的indexPath,而' assetURLs '或' sectionAssetURLs '不為空。
@param indexPath播放url的indexPath。
*/
- (void)playTheIndexPath:(NSIndexPath *)indexPath;
/**
播放url的indexPath,而' assetURLs '或' sectionAssetURLs '不為空。
@param indexPath播放url的indexPath
@param scrollToTop使用動(dòng)畫(huà)將當(dāng)前單元格滾動(dòng)到頂部。
*/
- (void)playTheIndexPath:(NSIndexPath *)indexPath scrollToTop:(BOOL)scrollToTop;
/**
播放url的indexPath,而' assetURLs '或' sectionAssetURLs '不為空。
@param indexPath播放url的indexPath
@param assetURL播放器URL。
@param scrollToTop使用動(dòng)畫(huà)將當(dāng)前單元格滾動(dòng)到頂部。
*/
- (void)playTheIndexPath:(NSIndexPath *)indexPath assetURL:(NSURL *)assetURL scrollToTop:(BOOL)scrollToTop;
/**
播放url的indexPath,而' assetURLs '或' sectionAssetURLs '不為空。
@param indexPath播放url的indexPath
@param scrollToTop使用動(dòng)畫(huà)將當(dāng)前單元格滾動(dòng)到頂部。
@param completionHandler滾動(dòng)完成回調(diào)。
*/
- (void)playTheIndexPath:(NSIndexPath *)indexPath scrollToTop:(BOOL)scrollToTop completionHandler:(void (^ __nullable)(void))completionHandler;
ZFPlayerMediaPlayback—播放器SDK遵守的協(xié)議
- 枚舉類(lèi)型:
/// 播放狀態(tài):未知、播放中、暫停、失敗、停止
typedef NS_ENUM(NSUInteger, ZFPlayerPlaybackState) {
ZFPlayerPlayStateUnknown = 0,
ZFPlayerPlayStatePlaying,
ZFPlayerPlayStatePaused,
ZFPlayerPlayStatePlayFailed,
ZFPlayerPlayStatePlayStopped
};
/// 加載狀態(tài):未知、就緒、可以播放、自動(dòng)播放、播放暫停
typedef NS_OPTIONS(NSUInteger, ZFPlayerLoadState) {
ZFPlayerLoadStateUnknown = 0,
ZFPlayerLoadStatePrepare = 1 << 0,
ZFPlayerLoadStatePlayable = 1 << 1,
ZFPlayerLoadStatePlaythroughOK = 1 << 2,
ZFPlayerLoadStateStalled = 1 << 3,
};
/// 播放畫(huà)面拉伸模式:無(wú)拉伸、等比例拉伸不裁剪、部分內(nèi)容裁剪按比例填充、非等比例填滿(mǎn)
typedef NS_ENUM(NSInteger, ZFPlayerScalingMode) {
ZFPlayerScalingModeNone,
ZFPlayerScalingModeAspectFit,
ZFPlayerScalingModeAspectFill,
ZFPlayerScalingModeFill
};
- 協(xié)議屬性:
/// 播放器視圖繼承于ZFPlayerView,處理一些手勢(shì)沖突
@property (nonatomic) ZFPlayerView *view;
/// 0...1.0,播放器音量,不影響設(shè)備的音量大小
@property (nonatomic) float volume;
/// 播放器是否靜音,不影響設(shè)備靜音
@property (nonatomic, getter=isMuted) BOOL muted;
/// 0.5...2,播放速率,正常速率為 1
@property (nonatomic) float rate;
/// 當(dāng)前播放時(shí)間
@property (nonatomic, readonly) NSTimeInterval currentTime;
/// 播放總時(shí)間
@property (nonatomic, readonly) NSTimeInterval totalTime;
/// 緩沖時(shí)間
@property (nonatomic, readonly) NSTimeInterval bufferTime;
/// 視頻播放定位時(shí)間
@property (nonatomic) NSTimeInterval seekTime;
/// 視頻是否正在播放中
@property (nonatomic, readonly) BOOL isPlaying;
/// 視頻播放視圖的填充模式,默認(rèn)不做任何拉伸
@property (nonatomic) ZFPlayerScalingMode scalingMode;
/// 檢查視頻播放是否準(zhǔn)備就緒,返回YES,調(diào)用play方法直接播放視頻;返回NO,調(diào)用play方法內(nèi)部自動(dòng)調(diào)用prepareToPlay方法進(jìn)行視頻播放準(zhǔn)備工作
@property (nonatomic, readonly) BOOL isPreparedToPlay;
/// 媒體播放資源URL
@property (nonatomic) NSURL *assetURL;
/// 視頻的尺寸
@property (nonatomic, readonly) CGSize presentationSize;
/// 視頻播放狀態(tài)
@property (nonatomic, readonly) ZFPlayerPlaybackState playState;
/// 視頻的加載狀態(tài)
@property (nonatomic, readonly) ZFPlayerLoadState loadState;
///------------------------------------
///如果沒(méi)有指定controlView,可以調(diào)用以下塊。
///如果你指定了controlView,下面的代碼塊不能在外部調(diào)用,只能用于“ZFPlayerController”調(diào)用。
///------------------------------------
/// 準(zhǔn)備播放
@property (nonatomic, copy, nullable) void(^playerPrepareToPlay)(id<ZFPlayerMediaPlayback> asset, NSURL *assetURL);
/// 開(kāi)始播放了
@property (nonatomic, copy, nullable) void(^playerReadyToPlay)(id<ZFPlayerMediaPlayback> asset, NSURL *assetURL);
/// 播放進(jìn)度改變
@property (nonatomic, copy, nullable) void(^playerPlayTimeChanged)(id<ZFPlayerMediaPlayback> asset, NSTimeInterval currentTime, NSTimeInterval duration);
/// 視頻緩沖進(jìn)度改變
@property (nonatomic, copy, nullable) void(^playerBufferTimeChanged)(id<ZFPlayerMediaPlayback> asset, NSTimeInterval bufferTime);
/// 視頻播放狀態(tài)改變
@property (nonatomic, copy, nullable) void(^playerPlayStatChanged)(id<ZFPlayerMediaPlayback> asset, ZFPlayerPlaybackState playState);
/// 視頻加載狀態(tài)改變
@property (nonatomic, copy, nullable) void(^playerLoadStatChanged)(id<ZFPlayerMediaPlayback> asset, ZFPlayerLoadState loadState);
/// 視頻播放已經(jīng)結(jié)束
@property (nonatomic, copy, nullable) void(^playerDidToEnd)(id<ZFPlayerMediaPlayback> asset);
// 視頻的尺寸改變了
@property (nonatomic, copy, nullable) void(^presentationSizeChanged)(id<ZFPlayerMediaPlayback> asset, CGSize size);
///------------------------------------
/// end
///------------------------------------
- 協(xié)議方法:
/// 視頻播放準(zhǔn)備,中斷除non-mixible之外的任何音頻會(huì)話(huà)
- (void)prepareToPlay;
/// 重新進(jìn)行視頻播放準(zhǔn)備
- (void)reloadPlayer;
/// 視頻播放
- (void)play;
/// 視頻暫停
- (void)pause;
/// 視頻重新播放
- (void)replay;
/// 視頻播放停止
- (void)stop;
/// 視頻播放當(dāng)前時(shí)間的畫(huà)面截圖
- (UIImage *)thumbnailImageAtCurrentTime;
/// 替換當(dāng)前媒體資源地址
- (void)replaceCurrentAssetURL:(NSURL *)assetURL;
/// 調(diào)節(jié)播放進(jìn)度
- (void)seekToTime:(NSTimeInterval)time completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;
ZFPlayerMediaControl—控制層遵守的協(xié)議
- 視頻狀態(tài)相關(guān)
/// 視頻播放準(zhǔn)備就緒
- (void)videoPlayer:(ZFPlayerController *)videoPlayer prepareToPlay:(NSURL *)assetURL;
/// 視頻播放狀態(tài)改變
- (void)videoPlayer:(ZFPlayerController *)videoPlayer playStateChanged:(ZFPlayerPlaybackState)state;
/// 視頻加載狀態(tài)改變
- (void)videoPlayer:(ZFPlayerController *)videoPlayer loadStateChanged:(ZFPlayerLoadState)state;
- 播放進(jìn)度
/// 視頻播放時(shí)間進(jìn)度
- (void)videoPlayer:(ZFPlayerController *)videoPlayer
currentTime:(NSTimeInterval)currentTime
totalTime:(NSTimeInterval)totalTime;
/// 視頻緩沖進(jìn)度
- (void)videoPlayer:(ZFPlayerController *)videoPlayer
bufferTime:(NSTimeInterval)bufferTime;
/// 視頻定位播放時(shí)間
- (void)videoPlayer:(ZFPlayerController *)videoPlayer
draggingTime:(NSTimeInterval)seekTime
totalTime:(NSTimeInterval)totalTime;
/// 視頻播放結(jié)束
- (void)videoPlayerPlayEnd:(ZFPlayerController *)videoPlayer;
- 鎖屏
/// 設(shè)置播放器鎖屏?xí)r的協(xié)議方法
- (void)lockedVideoPlayer:(ZFPlayerController *)videoPlayer lockedScreen:(BOOL)locked;
- 屏幕旋轉(zhuǎn)
/// 播放器全屏模式即將改變
- (void)videoPlayer:(ZFPlayerController *)videoPlayer orientationWillChange:(ZFOrientationObserver *)observer;
/// 播放器全屏模式已經(jīng)改變
- (void)videoPlayer:(ZFPlayerController *)videoPlayer orientationDidChanged:(ZFOrientationObserver *)observer;
/// 當(dāng)前網(wǎng)絡(luò)狀態(tài)發(fā)生變化
- (void)videoPlayer:(ZFPlayerController *)videoPlayer reachabilityChanged:(ZFReachabilityStatus)status;
- 手勢(shì)方法
/// 相關(guān)手勢(shì)設(shè)置
- (BOOL)gestureTriggerCondition:(ZFPlayerGestureControl *)gestureControl
gestureType:(ZFPlayerGestureType)gestureType
gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
touch:(UITouch *)touch;
/// 單擊
- (void)gestureSingleTapped:(ZFPlayerGestureControl *)gestureControl;
/// 雙擊
- (void)gestureDoubleTapped:(ZFPlayerGestureControl *)gestureControl;
/// 開(kāi)始拖拽
- (void)gestureBeganPan:(ZFPlayerGestureControl *)gestureControl
panDirection:(ZFPanDirection)direction
panLocation:(ZFPanLocation)location;
/// 拖拽中
- (void)gestureChangedPan:(ZFPlayerGestureControl *)gestureControl
panDirection:(ZFPanDirection)direction
panLocation:(ZFPanLocation)location
withVelocity:(CGPoint)velocity;
/// 拖拽結(jié)束
- (void)gestureEndedPan:(ZFPlayerGestureControl *)gestureControl
panDirection:(ZFPanDirection)direction
panLocation:(ZFPanLocation)location;
/// 捏合手勢(shì)變化
- (void)gesturePinched:(ZFPlayerGestureControl *)gestureControl
scale:(float)scale;
- scrollView上的播放器視圖方法
/**
scrollView中的播放器視圖將要出現(xiàn)的回調(diào)
*/
- (void)playerWillAppearInScrollView:(ZFPlayerController *)videoPlayer;
/**
scrollView中的播放器視圖已經(jīng)出現(xiàn)的回調(diào)
*/
- (void)playerDidAppearInScrollView:(ZFPlayerController *)videoPlayer;
/**
scrollView中的播放器視圖即將消失的回調(diào)
*/
- (void)playerWillDisappearInScrollView:(ZFPlayerController *)videoPlayer;
/**
scrollView中的播放器視圖已經(jīng)消失的回調(diào)
*/
- (void)playerDidDisappearInScrollView:(ZFPlayerController *)videoPlayer;
/**
scrollView中的播放器視圖正在顯示的回調(diào)
*/
- (void)playerAppearingInScrollView:(ZFPlayerController *)videoPlayer playerApperaPercent:(CGFloat)playerApperaPercent;
/**
scrollView中的播放器視圖正在消失的回調(diào)
*/
- (void)playerDisappearingInScrollView:(ZFPlayerController *)videoPlayer playerDisapperaPercent:(CGFloat)playerDisapperaPercent;
/**
小窗視圖顯示隱藏的回調(diào)
*/
- (void)videoPlayer:(ZFPlayerController *)videoPlayer floatViewShow:(BOOL)show;
代碼傳送門(mén):https://github.com/renzifeng/ZFPlayer
Author
- Weibo: @任子豐
- Email: zifeng1300@gmail.com
- QQ群: 213375947