前言
当前很多有关于视频播放的一些APP,基本在视频显示上面都是进行的自定义控件。进行了很多美化,便捷,以及多功能的支持。下面就和大家介绍一下我的自定义控件:
代码
- (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= @"视频标题";
[modelV addSubview:controlV];
}
说明
这里DJPlayControlView就是自定义的控件视图,当前显示的比较简单,因为未使用播放器,所以DJPlayControlView下面只是一个View(替代播放器),层次图如下:
这里播放器控件视图大小和播放器一样,只是视图层在播放器上面
#import
@class ASValueTrackingSlider;
@class MMMaterialDesignSpinner;
@interface DJPlayControlView : UIView
/** 标题 */
@property (nonatomic, strong) UILabel *titleLabel;
/** 开始播放按钮 */
@property (nonatomic, strong) UIButton *startBtn;
/** 当前播放时长label */
@property (nonatomic, strong) UILabel *currentTimeLabel;
/** 视频总时长label */
@property (nonatomic, strong) UILabel *totalTimeLabel;
/** 缓冲进度条 */
@property (nonatomic, strong) UIProgressView *progressView;
/** 滑杆 */
@property (nonatomic, strong) ASValueTrackingSlider *videoSlider;
/** 全屏按钮 */
@property (nonatomic, strong) UIButton *fullScreenBtn;
/** 锁定屏幕方向按钮 */
@property (nonatomic, strong) UIButton *lockBtn;
/** 系统菊花 */
@property (nonatomic, strong) MMMaterialDesignSpinner *activity;
/** 返回按钮*/
@property (nonatomic, strong) UIButton *backBtn;
/** 关闭按钮*/
@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;
/** 快进快退View*/
@property (nonatomic, strong) UIView *fastView;
/** 快进快退进度progress*/
@property (nonatomic, strong) UIProgressView *fastProgressView;
/** 快进快退时间*/
@property (nonatomic, strong) UILabel *fastTimeLabel;
/** 快进快退ImageView*/
@property (nonatomic, strong) UIImageView *fastImageView;
/** 当前选中的分辨率btn按钮 */
@property (nonatomic, weak ) UIButton *resoultionCurrentBtn;
/** 占位图 */
@property (nonatomic, strong) UIImageView *placeholderImageView;
/** 控制层消失时候在底部显示的播放进度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控制播放进度 */
@property (nonatomic, assign, getter=isDragged) BOOL dragged;
/** 是否播放结束 */
@property (nonatomic, assign, getter=isPlayEnd) BOOL playeEnd;
/** 是否全屏播放 */
@property (nonatomic, assign,getter=isFullScreen)BOOL fullScreen;
@end
详情请参照demo