ZFCustomControlView.m 20 KB

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