YOUPAIZFCustomControlView.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. //
  2. // YOUPAIZFCustomControlView.m
  3. // ZFPlayer_Example
  4. //
  5. // Created by 紫枫 on 2019/6/5.
  6. // Copyright © 2019 紫枫. All rights reserved.
  7. //
  8. #import "YOUPAIZFCustomControlView.h"
  9. #import "UIView+ZFFrame.h"
  10. #import "ZFUtilities.h"
  11. #import "ZFPlayer.h"
  12. #import "ZFSliderView.h"
  13. #import "UIImageView+ZFCache.h"
  14. @interface YOUPAIZFCustomControlView () <ZFSliderViewDelegate>
  15. /// 底部工具栏
  16. @property (nonatomic, strong) UIView *bottomToolView;
  17. /// 顶部工具栏
  18. @property (nonatomic, strong) UIView *topToolView;
  19. /// 标题
  20. @property (nonatomic, strong) UILabel *titleLabel;
  21. /// 播放或暂停按钮
  22. @property (nonatomic, strong) UIButton *playOrPauseBtn;
  23. /// 播放的当前时间
  24. @property (nonatomic, strong) UILabel *currentTimeLabel;
  25. /// 滑杆
  26. @property (nonatomic, strong) ZFSliderView *slider;
  27. /// 视频总时间
  28. @property (nonatomic, strong) UILabel *totalTimeLabel;
  29. /// 全屏按钮
  30. @property (nonatomic, strong) UIButton *fullScreenBtn;
  31. @property (nonatomic, assign) BOOL isShow;
  32. @property (nonatomic, assign) BOOL controlViewAppeared;
  33. @property (nonatomic, strong) dispatch_block_t afterBlock;
  34. @property (nonatomic, assign) NSTimeInterval sumTime;
  35. /// 底部播放进度
  36. @property (nonatomic, strong) ZFSliderView *bottomPgrogress;
  37. /// 加载loading
  38. @property (nonatomic, strong) ZFSpeedLoadingView *activity;
  39. /// 封面图
  40. @property (nonatomic, strong) UIImageView *coverImageView;
  41. @end
  42. @implementation YOUPAIZFCustomControlView
  43. @synthesize player = _player;
  44. - (instancetype)initWithFrame:(CGRect)frame {
  45. if (self = [super initWithFrame:frame]) {
  46. // 添加子控件
  47. [self addSubview:self.topToolView];
  48. [self addSubview:self.bottomToolView];
  49. [self addSubview:self.playOrPauseBtn];
  50. [self.topToolView addSubview:self.titleLabel];
  51. [self.bottomToolView addSubview:self.currentTimeLabel];
  52. [self.bottomToolView addSubview:self.slider];
  53. [self.bottomToolView addSubview:self.totalTimeLabel];
  54. [self.bottomToolView addSubview:self.fullScreenBtn];
  55. [self addSubview:self.bottomPgrogress];
  56. [self addSubview:self.activity];
  57. self.autoFadeTimeInterval = 0.2;
  58. self.autoHiddenTimeInterval = 2.5;
  59. // 设置子控件的响应事件
  60. [self makeSubViewsAction];
  61. [self youpaifresetControlView];
  62. self.clipsToBounds = YES;
  63. }
  64. return self;
  65. }
  66. - (void)makeSubViewsAction {
  67. [self.playOrPauseBtn addTarget:self action:@selector(playPauseButtonClickAction:) forControlEvents:UIControlEventTouchUpInside];
  68. [self.fullScreenBtn addTarget:self action:@selector(fullScreenButtonClickAction:) forControlEvents:UIControlEventTouchUpInside];
  69. }
  70. #pragma mark - ZFSliderViewDelegate
  71. - (void)sliderTouchBegan:(float)value {
  72. self.slider.isdragging = YES;
  73. }
  74. - (void)sliderTouchEnded:(float)value {
  75. if (self.player.totalTime > 0) {
  76. // @zf_weakify(self)
  77. [self.player seekToTime:self.player.totalTime*value completionHandler:^(BOOL finished) {
  78. // @zf_strongify(self)
  79. if (finished) {
  80. self.slider.isdragging = NO;
  81. }
  82. }];
  83. } else {
  84. self.slider.isdragging = NO;
  85. }
  86. }
  87. - (void)sliderValueChanged:(float)value {
  88. if (self.player.totalTime == 0) {
  89. self.slider.value = 0;
  90. return;
  91. }
  92. self.slider.isdragging = YES;
  93. NSString *currentTimeString = [ZFUtilities convertTimeSecond:self.player.totalTime*value];
  94. self.currentTimeLabel.text = currentTimeString;
  95. }
  96. - (void)sliderTapped:(float)value {
  97. if (self.player.totalTime > 0) {
  98. self.slider.isdragging = YES;
  99. // @zf_weakify(self)
  100. [self.player seekToTime:self.player.totalTime*value completionHandler:^(BOOL finished) {
  101. // @zf_strongify(self)
  102. if (finished) {
  103. self.slider.isdragging = NO;
  104. [self.player.currentPlayerManager play];
  105. }
  106. }];
  107. } else {
  108. self.slider.isdragging = NO;
  109. self.slider.value = 0;
  110. }
  111. }
  112. #pragma mark - action
  113. - (void)playPauseButtonClickAction:(UIButton *)sender {
  114. [self playOrPause];
  115. }
  116. - (void)fullScreenButtonClickAction:(UIButton *)sender {
  117. [self.player enterFullScreen:!self.player.isFullScreen animated:YES];
  118. }
  119. /// 根据当前播放状态取反
  120. - (void)playOrPause {
  121. self.playOrPauseBtn.selected = !self.playOrPauseBtn.isSelected;
  122. self.playOrPauseBtn.isSelected? [self.player.currentPlayerManager play]: [self.player.currentPlayerManager pause];
  123. }
  124. - (void)playBtnSelectedState:(BOOL)selected {
  125. self.playOrPauseBtn.selected = selected;
  126. }
  127. #pragma mark - 添加子控件约束
  128. - (void)layoutSubviews {
  129. [super layoutSubviews];
  130. CGFloat min_x = 0;
  131. CGFloat min_y = 0;
  132. CGFloat min_w = 0;
  133. CGFloat min_h = 0;
  134. CGFloat min_view_w = self.bounds.size.width;
  135. CGFloat min_view_h = self.bounds.size.height;
  136. CGFloat min_margin = 9;
  137. self.coverImageView.frame = self.bounds;
  138. min_w = 80;
  139. min_h = 80;
  140. self.activity.frame = CGRectMake(min_x, min_y, min_w, min_h);
  141. self.activity.zf_centerX = self.zf_centerX;
  142. self.activity.zf_centerY = self.zf_centerY + 10;
  143. min_x = 0;
  144. min_y = 0;
  145. min_w = min_view_w;
  146. min_h = (iPhoneX && self.player.isFullScreen) ? 80 : 40;
  147. self.topToolView.frame = CGRectMake(min_x, min_y, min_w, min_h);
  148. min_x = self.player.isFullScreen ? 40: 15;
  149. min_y = 0;
  150. min_w = min_view_w - min_x - 15;
  151. min_h = 30;
  152. self.titleLabel.frame = CGRectMake(min_x, min_y, min_w, min_h);
  153. self.titleLabel.zf_centerY = self.topToolView.zf_centerY;
  154. min_h = (iPhoneX && self.player.isFullScreen) ? 100 : 40;
  155. min_x = 0;
  156. min_y = min_view_h - min_h;
  157. min_w = min_view_w;
  158. self.bottomToolView.frame = CGRectMake(min_x, min_y, min_w, min_h);
  159. min_x = 0;
  160. min_y = 0;
  161. min_w = 44;
  162. min_h = min_w;
  163. self.playOrPauseBtn.frame = CGRectMake(min_x, min_y, min_w, min_h);
  164. self.playOrPauseBtn.center = self.center;
  165. min_x = (iPhoneX && self.player.isFullScreen) ? 44: 15;
  166. min_w = 62;
  167. min_h = 28;
  168. min_y = (self.bottomToolView.zf_height - min_h)/2;
  169. self.currentTimeLabel.frame = CGRectMake(min_x, min_y, min_w, min_h);
  170. min_w = 28;
  171. min_h = min_w;
  172. min_x = self.bottomToolView.zf_width - min_w - ((iPhoneX && self.player.isFullScreen) ? 44: min_margin);
  173. min_y = 0;
  174. self.fullScreenBtn.frame = CGRectMake(min_x, min_y, min_w, min_h);
  175. self.fullScreenBtn.zf_centerY = self.currentTimeLabel.zf_centerY;
  176. min_w = 62;
  177. min_h = 28;
  178. min_x = self.fullScreenBtn.zf_left - min_w - 4;
  179. min_y = 0;
  180. self.totalTimeLabel.frame = CGRectMake(min_x, min_y, min_w, min_h);
  181. self.totalTimeLabel.zf_centerY = self.currentTimeLabel.zf_centerY;
  182. min_x = self.currentTimeLabel.zf_right + 4;
  183. min_y = 0;
  184. min_w = self.totalTimeLabel.zf_left - min_x - 4;
  185. min_h = 30;
  186. self.slider.frame = CGRectMake(min_x, min_y, min_w, min_h);
  187. self.slider.zf_centerY = self.currentTimeLabel.zf_centerY;
  188. min_x = 0;
  189. min_y = min_view_h - 1;
  190. min_w = min_view_w;
  191. min_h = 1;
  192. self.bottomPgrogress.frame = CGRectMake(min_x, min_y, min_w, min_h);
  193. if (!self.isShow) {
  194. self.topToolView.zf_y = -self.topToolView.zf_height;
  195. self.bottomToolView.zf_y = self.zf_height;
  196. self.playOrPauseBtn.alpha = 0;
  197. } else {
  198. self.topToolView.zf_y = 0;
  199. self.bottomToolView.zf_y = self.zf_height - self.bottomToolView.zf_height;
  200. self.playOrPauseBtn.alpha = 1;
  201. }
  202. }
  203. #pragma mark - private
  204. /** 重置ControlView */
  205. - (void)youpaifresetControlView {
  206. self.bottomToolView.alpha = 1;
  207. self.slider.value = 0;
  208. self.slider.bufferValue = 0;
  209. self.currentTimeLabel.text = @"00:00";
  210. self.totalTimeLabel.text = @"00:00";
  211. self.backgroundColor = [UIColor clearColor];
  212. self.playOrPauseBtn.selected = YES;
  213. self.titleLabel.text = @"";
  214. }
  215. - (void)showControlView {
  216. self.topToolView.alpha = 1;
  217. self.bottomToolView.alpha = 1;
  218. self.isShow = YES;
  219. self.topToolView.zf_y = 0;
  220. self.bottomToolView.zf_y = self.zf_height - self.bottomToolView.zf_height;
  221. self.playOrPauseBtn.alpha = 1;
  222. self.player.statusBarHidden = NO;
  223. }
  224. - (void)hideControlView {
  225. self.isShow = NO;
  226. self.topToolView.zf_y = -self.topToolView.zf_height;
  227. self.bottomToolView.zf_y = self.zf_height;
  228. self.player.statusBarHidden = NO;
  229. self.playOrPauseBtn.alpha = 0;
  230. self.topToolView.alpha = 0;
  231. self.bottomToolView.alpha = 0;
  232. }
  233. - (void)autoFadeOutControlView {
  234. self.controlViewAppeared = YES;
  235. [self cancelAutoFadeOutControlView];
  236. // @zf_weakify(self)
  237. self.afterBlock = dispatch_block_create(0, ^{
  238. // @zf_strongify(self)
  239. [self hideControlViewWithAnimated:YES];
  240. });
  241. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.autoHiddenTimeInterval * NSEC_PER_SEC)), dispatch_get_main_queue(),self.afterBlock);
  242. }
  243. /// 取消延时隐藏controlView的方法
  244. - (void)cancelAutoFadeOutControlView {
  245. if (self.afterBlock) {
  246. dispatch_block_cancel(self.afterBlock);
  247. self.afterBlock = nil;
  248. }
  249. }
  250. /// 隐藏控制层
  251. - (void)hideControlViewWithAnimated:(BOOL)animated {
  252. self.controlViewAppeared = NO;
  253. [UIView animateWithDuration:animated ? self.autoFadeTimeInterval : 0 animations:^{
  254. [self hideControlView];
  255. } completion:^(BOOL finished) {
  256. self.bottomPgrogress.hidden = NO;
  257. }];
  258. }
  259. /// 显示控制层
  260. - (void)showControlViewWithAnimated:(BOOL)animated {
  261. self.controlViewAppeared = YES;
  262. [self autoFadeOutControlView];
  263. [UIView animateWithDuration:animated ? self.autoFadeTimeInterval : 0 animations:^{
  264. [self showControlView];
  265. } completion:^(BOOL finished) {
  266. self.bottomPgrogress.hidden = YES;
  267. }];
  268. }
  269. - (BOOL)shouldResponseGestureWithPoint:(CGPoint)point withGestureType:(ZFPlayerGestureType)type touch:(nonnull UITouch *)touch {
  270. CGRect sliderRect = [self.bottomToolView convertRect:self.slider.frame toView:self];
  271. if (CGRectContainsPoint(sliderRect, point)) {
  272. return NO;
  273. }
  274. return YES;
  275. }
  276. /**
  277. 设置标题、封面、全屏模式
  278. @param title 视频的标题
  279. @param coverUrl 视频的封面,占位图默认是灰色的
  280. @param fullScreenMode 全屏模式
  281. */
  282. - (void)showTitle:(NSString *)title coverURLString:(NSString *)coverUrl fullScreenMode:(ZFFullScreenMode)fullScreenMode {
  283. // UIImage *placeholder = [ZFUtilities imageWithColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1] size:self.coverImageView.bounds.size];
  284. [self youpaifresetControlView];
  285. [self layoutIfNeeded];
  286. [self setNeedsDisplay];
  287. self.titleLabel.text = title;
  288. self.player.orientationObserver.fullScreenMode = fullScreenMode;
  289. // [self.player.currentPlayerManager.view.coverImageView setImageWithURLString:coverUrl placeholder:placeholder];
  290. }
  291. /// 调节播放进度slider和当前时间更新
  292. - (void)sliderValueChanged:(CGFloat)value currentTimeString:(NSString *)timeString {
  293. self.slider.value = value;
  294. self.currentTimeLabel.text = timeString;
  295. self.slider.isdragging = YES;
  296. [UIView animateWithDuration:0.3 animations:^{
  297. self.slider.sliderBtn.transform = CGAffineTransformMakeScale(1.2, 1.2);
  298. }];
  299. }
  300. /// 滑杆结束滑动
  301. - (void)sliderChangeEnded {
  302. self.slider.isdragging = NO;
  303. [UIView animateWithDuration:0.3 animations:^{
  304. self.slider.sliderBtn.transform = CGAffineTransformIdentity;
  305. }];
  306. }
  307. #pragma mark - ZFPlayerControlViewDelegate
  308. /// 手势筛选,返回NO不响应该手势
  309. - (BOOL)gestureTriggerCondition:(ZFPlayerGestureControl *)gestureControl gestureType:(ZFPlayerGestureType)gestureType gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer touch:(nonnull UITouch *)touch {
  310. CGPoint point = [touch locationInView:self];
  311. if (self.player.isSmallFloatViewShow && !self.player.isFullScreen && gestureType != ZFPlayerGestureTypeSingleTap) {
  312. return NO;
  313. }
  314. return [self shouldResponseGestureWithPoint:point withGestureType:gestureType touch:touch];
  315. }
  316. /// 单击手势事件
  317. - (void)gestureSingleTapped:(ZFPlayerGestureControl *)gestureControl {
  318. if (!self.player) return;
  319. if (self.player.isSmallFloatViewShow && !self.player.isFullScreen) {
  320. [self.player enterFullScreen:YES animated:YES];
  321. } else {
  322. if (self.controlViewAppeared) {
  323. [self hideControlViewWithAnimated:YES];
  324. } else {
  325. /// 显示之前先把控制层复位,先隐藏后显示
  326. [self hideControlViewWithAnimated:NO];
  327. [self showControlViewWithAnimated:YES];
  328. }
  329. }
  330. }
  331. /// 双击手势事件
  332. - (void)gestureDoubleTapped:(ZFPlayerGestureControl *)gestureControl {
  333. [self playOrPause];
  334. }
  335. /// 捏合手势事件,这里改变了视频的填充模式
  336. - (void)gesturePinched:(ZFPlayerGestureControl *)gestureControl scale:(float)scale {
  337. if (scale > 1) {
  338. self.player.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFill;
  339. } else {
  340. self.player.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFit;
  341. }
  342. }
  343. /// 准备播放
  344. - (void)videoPlayer:(ZFPlayerController *)videoPlayer prepareToPlay:(NSURL *)assetURL {
  345. [self hideControlViewWithAnimated:NO];
  346. }
  347. /// 播放状态改变
  348. - (void)videoPlayer:(ZFPlayerController *)videoPlayer playStateChanged:(ZFPlayerPlaybackState)state {
  349. if (state == ZFPlayerPlayStatePlaying) {
  350. [self playBtnSelectedState:YES];
  351. /// 开始播放时候判断是否显示loading
  352. if (videoPlayer.currentPlayerManager.loadState == ZFPlayerLoadStateStalled) {
  353. [self.activity startAnimating];
  354. } else if ((videoPlayer.currentPlayerManager.loadState == ZFPlayerLoadStateStalled || videoPlayer.currentPlayerManager.loadState == ZFPlayerLoadStatePrepare)) {
  355. [self.activity startAnimating];
  356. }
  357. } else if (state == ZFPlayerPlayStatePaused) {
  358. [self playBtnSelectedState:NO];
  359. /// 暂停的时候隐藏loading
  360. [self.activity stopAnimating];
  361. } else if (state == ZFPlayerPlayStatePlayFailed) {
  362. [self.activity stopAnimating];
  363. }
  364. }
  365. /// 加载状态改变
  366. - (void)videoPlayer:(ZFPlayerController *)videoPlayer loadStateChanged:(ZFPlayerLoadState)state {
  367. if (state == ZFPlayerLoadStatePrepare) {
  368. self.coverImageView.hidden = NO;
  369. } else if (state == ZFPlayerLoadStatePlaythroughOK || state == ZFPlayerLoadStatePlayable) {
  370. self.coverImageView.hidden = YES;
  371. self.player.currentPlayerManager.view.backgroundColor = [UIColor blackColor];
  372. }
  373. if (state == ZFPlayerLoadStateStalled && videoPlayer.currentPlayerManager.isPlaying) {
  374. [self.activity startAnimating];
  375. } else if ((state == ZFPlayerLoadStateStalled || state == ZFPlayerLoadStatePrepare) && videoPlayer.currentPlayerManager.isPlaying) {
  376. [self.activity startAnimating];
  377. } else {
  378. [self.activity stopAnimating];
  379. }
  380. }
  381. /// 播放进度改变回调
  382. - (void)videoPlayer:(ZFPlayerController *)videoPlayer currentTime:(NSTimeInterval)currentTime totalTime:(NSTimeInterval)totalTime {
  383. if (!self.slider.isdragging) {
  384. NSString *currentTimeString = [ZFUtilities convertTimeSecond:currentTime];
  385. self.currentTimeLabel.text = currentTimeString;
  386. NSString *totalTimeString = [ZFUtilities convertTimeSecond:totalTime];
  387. self.totalTimeLabel.text = totalTimeString;
  388. self.slider.value = videoPlayer.progress;
  389. }
  390. self.bottomPgrogress.value = videoPlayer.progress;
  391. }
  392. /// 缓冲改变回调
  393. - (void)videoPlayer:(ZFPlayerController *)videoPlayer bufferTime:(NSTimeInterval)bufferTime {
  394. self.slider.bufferValue = videoPlayer.bufferProgress;
  395. self.bottomPgrogress.bufferValue = videoPlayer.bufferProgress;
  396. }
  397. - (void)videoPlayer:(ZFPlayerController *)videoPlayer presentationSizeChanged:(CGSize)size {
  398. }
  399. /// 视频view即将旋转
  400. - (void)videoPlayer:(ZFPlayerController *)videoPlayer orientationWillChange:(ZFOrientationObserver *)observer {
  401. if (videoPlayer.isSmallFloatViewShow) {
  402. if (observer.isFullScreen) {
  403. self.controlViewAppeared = NO;
  404. [self cancelAutoFadeOutControlView];
  405. }
  406. }
  407. if (self.controlViewAppeared) {
  408. [self showControlViewWithAnimated:NO];
  409. } else {
  410. [self hideControlViewWithAnimated:NO];
  411. }
  412. }
  413. /// 视频view已经旋转
  414. - (void)videoPlayer:(ZFPlayerController *)videoPlayer orientationDidChanged:(ZFOrientationObserver *)observer {
  415. if (self.controlViewAppeared) {
  416. [self showControlViewWithAnimated:NO];
  417. } else {
  418. [self hideControlViewWithAnimated:NO];
  419. }
  420. [self layoutIfNeeded];
  421. [self setNeedsDisplay];
  422. }
  423. /// 锁定旋转方向
  424. - (void)lockedVideoPlayer:(ZFPlayerController *)videoPlayer lockedScreen:(BOOL)locked {
  425. [self showControlViewWithAnimated:YES];
  426. }
  427. #pragma mark - setter
  428. - (void)setPlayer:(ZFPlayerController *)player {
  429. _player = player;
  430. }
  431. #pragma mark - getter
  432. - (UIView *)topToolView {
  433. if (!_topToolView) {
  434. _topToolView = [[UIView alloc] init];
  435. UIImage *image = ZFPlayer_Image(@"ZFPlayer_top_shadow");
  436. _topToolView.layer.contents = (id)image.CGImage;
  437. }
  438. return _topToolView;
  439. }
  440. - (UILabel *)titleLabel {
  441. if (!_titleLabel) {
  442. _titleLabel = [[UILabel alloc] init];
  443. _titleLabel.textColor = [UIColor whiteColor];
  444. _titleLabel.font = [UIFont systemFontOfSize:15.0];
  445. }
  446. return _titleLabel;
  447. }
  448. - (UIView *)bottomToolView {
  449. if (!_bottomToolView) {
  450. _bottomToolView = [[UIView alloc] init];
  451. UIImage *image = ZFPlayer_Image(@"ZFPlayer_bottom_shadow");
  452. _bottomToolView.layer.contents = (id)image.CGImage;
  453. }
  454. return _bottomToolView;
  455. }
  456. - (UIButton *)playOrPauseBtn {
  457. if (!_playOrPauseBtn) {
  458. _playOrPauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  459. [_playOrPauseBtn setImage:ZFPlayer_Image(@"new_allPlay_44x44_") forState:UIControlStateNormal];
  460. [_playOrPauseBtn setImage:ZFPlayer_Image(@"new_allPause_44x44_") forState:UIControlStateSelected];
  461. }
  462. return _playOrPauseBtn;
  463. }
  464. - (UILabel *)currentTimeLabel {
  465. if (!_currentTimeLabel) {
  466. _currentTimeLabel = [[UILabel alloc] init];
  467. _currentTimeLabel.textColor = [UIColor whiteColor];
  468. _currentTimeLabel.font = [UIFont systemFontOfSize:14.0f];
  469. _currentTimeLabel.textAlignment = NSTextAlignmentCenter;
  470. }
  471. return _currentTimeLabel;
  472. }
  473. - (ZFSliderView *)slider {
  474. if (!_slider) {
  475. _slider = [[ZFSliderView alloc] init];
  476. _slider.delegate = self;
  477. _slider.maximumTrackTintColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.8];
  478. _slider.bufferTrackTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
  479. _slider.minimumTrackTintColor = [UIColor whiteColor];
  480. [_slider setThumbImage:ZFPlayer_Image(@"ZFPlayer_slider") forState:UIControlStateNormal];
  481. _slider.sliderHeight = 2;
  482. }
  483. return _slider;
  484. }
  485. - (UILabel *)totalTimeLabel {
  486. if (!_totalTimeLabel) {
  487. _totalTimeLabel = [[UILabel alloc] init];
  488. _totalTimeLabel.textColor = [UIColor whiteColor];
  489. _totalTimeLabel.font = [UIFont systemFontOfSize:14.0f];
  490. _totalTimeLabel.textAlignment = NSTextAlignmentCenter;
  491. }
  492. return _totalTimeLabel;
  493. }
  494. - (UIButton *)fullScreenBtn {
  495. if (!_fullScreenBtn) {
  496. _fullScreenBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  497. [_fullScreenBtn setImage:ZFPlayer_Image(@"ZFPlayer_fullscreen") forState:UIControlStateNormal];
  498. }
  499. return _fullScreenBtn;
  500. }
  501. - (UIImageView *)coverImageView {
  502. if (!_coverImageView) {
  503. _coverImageView = [[UIImageView alloc] init];
  504. _coverImageView.userInteractionEnabled = YES;
  505. _coverImageView.contentMode = UIViewContentModeScaleAspectFit;
  506. }
  507. return _coverImageView;
  508. }
  509. - (ZFSliderView *)bottomPgrogress {
  510. if (!_bottomPgrogress) {
  511. _bottomPgrogress = [[ZFSliderView alloc] init];
  512. _bottomPgrogress.maximumTrackTintColor = [UIColor clearColor];
  513. _bottomPgrogress.minimumTrackTintColor = [UIColor whiteColor];
  514. _bottomPgrogress.bufferTrackTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
  515. _bottomPgrogress.sliderHeight = 1;
  516. _bottomPgrogress.isHideSliderBlock = NO;
  517. }
  518. return _bottomPgrogress;
  519. }
  520. @end