IJKMediaPlayback
pragma mark - IJKMediaPlayback
#pragma mark 通知
IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification; // 播放狀態(tài)的改變 代替 MPMoviePlayerContentPreloadDidFinishNotification
IJKMPMoviePlayerScalingModeDidChangeNotification; // 縮放比例的改變
IJKMPMoviePlayerPlaybackDidFinishNotification;
IJKMPMoviePlayerPlaybackDidFinishReasonUserInfoKey; // NSNumber (IJKMPMovieFinishReason)
當電影播放結(jié)束或用戶退出播放時調(diào)用。
IJKMPMoviePlayerPlaybackStateDidChangeNotification; // 用戶改變播放狀態(tài)改變時調(diào)用
IJKMPMoviePlayerLoadStateDidChangeNotification; // 當網(wǎng)絡加載狀態(tài)發(fā)生變化時。
IJKMPMoviePlayerIsAirPlayVideoActiveDidChangeNotification; // 當視頻通過 AirPlay 開始播放視頻或結(jié)束時調(diào)用
Movie Property Notifications
屬性相關(guān)的同時聲明
IJKMPMovieNaturalSizeAvailableNotification; // 在執(zhí)行 prepareToPlay 時開始異步確定影片屬性,當相關(guān)屬性變?yōu)橛行Э捎脮r調(diào)用該通知
IJKMPMoviePlayerVideoDecoderOpenNotification; // 視頻 編譯器打開通知
IJKMPMoviePlayerFirstVideoFrameRenderedNotification; // 視頻 視頻第一幀時通知
IJKMPMoviePlayerFirstAudioFrameRenderedNotification; // 視頻 音頻第一段時通知
#pragma mark 枚舉
typedef NS_OPTIONS(NSUInteger, IJKMPMovieLoadState) {
IJKMPMovieLoadStateUnknown = 0, // 未知狀態(tài)
IJKMPMovieLoadStatePlayable = 1 << 0, //
IJKMPMovieLoadStatePlaythroughOK = 1 << 1, // 當shouldAutoPlay 為Yes時,將開始在這種狀態(tài)
IJKMPMovieLoadStateStalled = 1 << 2, // 播放后,自動設定為該方法
};
typedef NS_ENUM(NSInteger, IJKMPMoviePlaybackState) {
IJKMPMoviePlaybackStateStopped, // 播放停止
IJKMPMoviePlaybackStatePlaying, // 開始播放
IJKMPMoviePlaybackStatePaused, // 暫停播放
IJKMPMoviePlaybackStateInterrupted, // 播放間斷
IJKMPMoviePlaybackStateSeekingForward, // 播放快進
IJKMPMoviePlaybackStateSeekingBackward // 播放后退
};
typedef NS_ENUM(NSInteger, IJKMPMovieScalingMode) {
IJKMPMovieScalingModeNone, // 沒有縮放比例
IJKMPMovieScalingModeAspectFit, //尺寸比例不變填滿屏幕為止
IJKMPMovieScalingModeAspectFill, // 尺寸比例不變填滿屏幕,可能造成內(nèi)容缺少
IJKMPMovieScalingModeFill // 尺寸比例變形也會填滿屏幕
};
int reason =[[[notification userInfo] valueForKey:IJKMPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
用于IJKMPMoviePlayerPlaybackDidFinishReasonUserInfoKey通知中,判斷reason為一枚舉
typedef NS_ENUM(NSInteger, IJKMPMovieFinishReason) {
IJKMPMovieFinishReasonPlaybackEnded, // 完成原因:播放結(jié)束
IJKMPMovieFinishReasonPlaybackError, // 完成原因:播放出現(xiàn)錯誤
IJKMPMovieFinishReasonUserExited // 完成原因:出現(xiàn)用戶行為退出
};
Thumbnails (縮略圖)
獲取在指定播放時間的視頻縮略圖,第一個參數(shù)是獲取縮略圖的時間點數(shù)組;第二個參數(shù)代表時間點精度,枚舉類型
typedef NS_ENUM(NSInteger, IJKMPMovieTimeOption) {
IJKMPMovieTimeOptionNearestKeyFrame, // 時間點附近
IJKMPMovieTimeOptionExact //準確時間
};
#pragma mark Attribute & Method
- (void)prepareToPlay; // 播放準備
- (void)play; // 播放
- (void)pause; // 暫停
- (void)stop; // 停止播放
- (BOOL)isPlaying; // 是否正在播放中
- (void)setPauseInBackground:(BOOL)pause; // 后臺暫停
- (void)shutdown; // ******這句要寫在viewDidDisappear中,否則可能會造成vc不會被釋放******
@property(nonatomic, readonly) UIView *view; // 用于顯示視頻播放的view,調(diào)用次view
@property(nonatomic) NSTimeInterval currentPlaybackTime; // 當前播放的時間點
@property(nonatomic, readonly) NSTimeInterval duration; // 總時長
@property(nonatomic, readonly) NSTimeInterval playableDuration; // 可播放時長
@property(nonatomic, readonly) NSInteger bufferingProgress; // 緩沖進度
@property(nonatomic, readonly) BOOL isPreparedToPlay; // 準備播放
@property(nonatomic, readonly) IJKMPMoviePlaybackState playbackState; // 播放終止狀態(tài)枚舉
@property(nonatomic, readonly) IJKMPMovieLoadState loadState; // 加載狀態(tài)枚舉
@property(nonatomic, readonly) int64_t numberOfBytesTransferred; // 傳輸字節(jié)數(shù)
@property(nonatomic, readonly) CGSize naturalSize; // 視頻原始顯示View size,
@property(nonatomic) IJKMPMovieScalingMode scalingMode; // 視頻尺寸模式
@property(nonatomic) BOOL shouldAutoplay; // 需要自動播放
@property (nonatomic) BOOL allowsMediaAirPlay; // 支持AirPlay 媒體
@property (nonatomic) BOOL isDanmakuMediaAirPlay; // 支持彈幕AirPlay媒體
@property (nonatomic, readonly) BOOL airPlayMediaActive; //AirPlay 是否活躍
@property (nonatomic) float playbackRate; // 返回音頻/視頻的當前播放速度 0-1
- (UIImage *)thumbnailImageAtCurrentTime; //獲取當前時間的封面幀圖片
IJKMediaUrlOpenDelegate && IJKMediaUrlOpenData
typedef NS_ENUM(NSInteger, IJKMediaUrlOpenType) {
IJKMediaUrlOpenEvent_ConcatResolveSegment = 0x10000,
IJKMediaUrlOpenEvent_TcpOpen = 0x10001,
IJKMediaUrlOpenEvent_HttpOpen = 0x10002,
IJKMediaUrlOpenEvent_LiveOpen = 0x10004,
};
- (id)initWithUrl:(NSString *)url
openType:(IJKMediaUrlOpenType)openType
segmentIndex:(int)segmentIndex
retryCounter:(int)retryCounter;
@property(nonatomic, readonly) IJKMediaUrlOpenType openType;
@property(nonatomic, readonly) int segmentIndex;
@property(nonatomic, readonly) int retryCounter; // 重試次數(shù)
@property(nonatomic, retain) NSString *url;
@property(nonatomic) int error; // 錯誤提示,發(fā)生錯誤該屬性為負
@property(nonatomic, getter=isHandled) BOOL handled; // 如果url發(fā)生改變,該數(shù)值變?yōu)閅es
@property(nonatomic, getter=isUrlChanged) BOOL urlChanged; // 通過改變url設置為YES
IJKMediaModule
@property(atomic, getter=isAppIdleTimerDisabled) BOOL appIdleTimerDisabled; // 如果不希望在運行程序時鎖屏 ,設置為YES
@property(atomic, getter=isMediaModuleIdleTimerDisabled) BOOL mediaModuleIdleTimerDisabled;
IJKFFOptions
typedef enum IJKFFOptionCategory {
kIJKFFOptionCategoryFormat = 1,
kIJKFFOptionCategoryCodec = 2,
kIJKFFOptionCategorySws = 3,
kIJKFFOptionCategoryPlayer = 4,
} IJKFFOptionCategory;
// 解碼器選項 skip_loop_filter & skip_frame
typedef enum IJKAVDiscard {
/* We leave some space between them for extensions (drop some
* keyframes for intra-only or drop just some bidir frames). */
IJK_AVDISCARD_NONE =-16, ///< discard nothing
IJK_AVDISCARD_DEFAULT = 0, ///< 如果包大小為0,責拋棄無效的包
IJK_AVDISCARD_NONREF = 8, ///< 拋棄非參考幀(I幀)
IJK_AVDISCARD_BIDIR = 16, ///< 拋棄B幀
IJK_AVDISCARD_NONKEY = 32, ///< 拋棄除關(guān)鍵幀以外的,比如B,P幀
IJK_AVDISCARD_ALL = 48, ///< 拋棄所有的幀
} IJKAVDiscard;
+(IJKFFOptions *)optionsByDefault; //初始化用
-(void)applyTo:(struct IjkMediaPlayer *)mediaPlayer;
- (void)setOptionValue:(NSString *)value forKey:(NSString *)key ofCategory:(IJKFFOptionCategory)category;
- (void)setOptionIntValue:(int64_t)value forKey:(NSString *)key ofCategory:(IJKFFOptionCategory)category;
-(void)setFormatOptionValue: (NSString *)value forKey:(NSString *)key;
-(void)setCodecOptionValue: (NSString *)value forKey:(NSString *)key;
-(void)setSwsOptionValue: (NSString *)value forKey:(NSString *)key;
-(void)setPlayerOptionValue: (NSString *)value forKey:(NSString *)key;
-(void)setFormatOptionIntValue: (int64_t)value forKey:(NSString *)key;
-(void)setCodecOptionIntValue: (int64_t)value forKey:(NSString *)key;
-(void)setSwsOptionIntValue: (int64_t)value forKey:(NSString *)key;
-(void)setPlayerOptionIntValue: (int64_t)value forKey:(NSString *)key; // value:1 forKey:@"videotoolbox";開啟硬件解碼
@property(nonatomic) BOOL useRenderQueue; // 使用渲染隊列
@property(nonatomic) BOOL showHudView; // 顯示加載指示器視圖
由Options 中可得知它的所有屬性
start-on-prepared (開始準備);
overlay-format、max-fps(最大fps);
framedrop(跳幀開關(guān):當cpu過慢時進行幀降低處理);
videotoolbox-max-frame-width(指定最大寬度);
videotoolbox(解碼模式 0:軟解、1:硬解碼);
video-pictq-size ;
ijkinject-opaque;
user-agent ;
auto_convert(自動轉(zhuǎn)屏開關(guān));
timeout(超時時間);
reconnect (重連次數(shù));
safe ;
skip_frame;
skip_loop_filter;
全部參數(shù)查看ijkplayer 中 :
//60行 static const AVOption ffp_context_options[]