ZFCustomControlView.m 20 KB

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