IOS 自定義播放器控件

前言


當(dāng)前很多有關(guān)于視頻播放的一些APP,基本在視頻顯示上面都是進(jìn)行的自定義控件。進(jìn)行了很多美化,便捷,以及多功能的支持。下面就和大家介紹一下我的自定義控件:


示例圖

代碼

- (void)viewDidLoad {

[super viewDidLoad];

UIView *modelV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 300)];

modelV.center = self.view.center;

modelV.backgroundColor = [UIColor grayColor];

[self.view addSubview:modelV];

DJPlayControlView *controlV = [[DJPlayControlView alloc] init];

controlV.frame = CGRectMake(0, 0, 400, 300);

controlV.titleLabel.text= @"視頻標(biāo)題";

[modelV addSubview:controlV];

}

說明

這里DJPlayControlView就是自定義的控件視圖,當(dāng)前顯示的比較簡單,因為未使用播放器,所以DJPlayControlView下面只是一個View(替代播放器),層次圖如下:



這里播放器控件視圖大小和播放器一樣,只是視圖層在播放器上面

#import <UIKit/UIKit.h>

@class ASValueTrackingSlider;

@class MMMaterialDesignSpinner;

@interface DJPlayControlView : UIView

/** 標(biāo)題 */

@property (nonatomic, strong) UILabel? ? ? ? ? ? ? ? *titleLabel;

/** 開始播放按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *startBtn;

/** 當(dāng)前播放時長label */

@property (nonatomic, strong) UILabel? ? ? ? ? ? ? ? *currentTimeLabel;

/** 視頻總時長label */

@property (nonatomic, strong) UILabel? ? ? ? ? ? ? ? *totalTimeLabel;

/** 緩沖進(jìn)度條 */

@property (nonatomic, strong) UIProgressView? ? ? ? ? *progressView;

/** 滑桿 */

@property (nonatomic, strong) ASValueTrackingSlider? *videoSlider;

/** 全屏按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *fullScreenBtn;

/** 鎖定屏幕方向按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *lockBtn;

/** 系統(tǒng)菊花 */

@property (nonatomic, strong) MMMaterialDesignSpinner *activity;

/** 返回按鈕*/

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *backBtn;

/** 關(guān)閉按鈕*/

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *closeBtn;

/** 重播按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *repeatBtn;

/** bottomView*/

@property (nonatomic, strong) UIImageView? ? ? ? ? ? *bottomImageView;

/** topView */

@property (nonatomic, strong) UIImageView? ? ? ? ? ? *topImageView;

/** 緩存按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *downLoadBtn;

/** 切換分辨率按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *resolutionBtn;

/** 分辨率的View */

@property (nonatomic, strong) UIView? ? ? ? ? ? ? ? ? *resolutionView;

/** 播放按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *playeBtn;

/** 加載失敗按鈕 */

@property (nonatomic, strong) UIButton? ? ? ? ? ? ? ? *failBtn;

/** 快進(jìn)快退View*/

@property (nonatomic, strong) UIView? ? ? ? ? ? ? ? ? *fastView;

/** 快進(jìn)快退進(jìn)度progress*/

@property (nonatomic, strong) UIProgressView? ? ? ? ? *fastProgressView;

/** 快進(jìn)快退時間*/

@property (nonatomic, strong) UILabel? ? ? ? ? ? ? ? *fastTimeLabel;

/** 快進(jìn)快退ImageView*/

@property (nonatomic, strong) UIImageView? ? ? ? ? ? *fastImageView;

/** 當(dāng)前選中的分辨率btn按鈕 */

@property (nonatomic, weak? ) UIButton? ? ? ? ? ? ? ? *resoultionCurrentBtn;

/** 占位圖 */

@property (nonatomic, strong) UIImageView? ? ? ? ? ? *placeholderImageView;

/** 控制層消失時候在底部顯示的播放進(jìn)度progress */

@property (nonatomic, strong) UIProgressView? ? ? ? ? *bottomProgressView;

/** 分辨率的名稱 */

@property (nonatomic, strong) NSArray? ? ? ? ? ? ? ? *resolutionArray;

/** 顯示控制層 */

@property (nonatomic, assign, getter=isShowing) BOOL? showing;

/** 小屏播放 */

@property (nonatomic, assign, getter=isShrink ) BOOL? shrink;

/** 在cell上播放 */

@property (nonatomic, assign, getter=isCellVideo)BOOL cellVideo;

/** 是否拖拽slider控制播放進(jìn)度 */

@property (nonatomic, assign, getter=isDragged) BOOL? dragged;

/** 是否播放結(jié)束 */

@property (nonatomic, assign, getter=isPlayEnd) BOOL? playeEnd;

/** 是否全屏播放 */

@property (nonatomic, assign,getter=isFullScreen)BOOL fullScreen;

@end

詳情請參照demo

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容