YOUPAIZYSeeLikeVideoVC.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // YOUPAIZYSeeLikeVideoVC.m
  3. // MEISHI
  4. //
  5. // Created by Elaine on 2021/2/3.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYSeeLikeVideoVC.h"
  9. #import "ZFPlayer.h"
  10. #import "ZFAVPlayerManager.h"
  11. #import "YOUPAIZFCustomControlView.h"
  12. @interface YOUPAIZYSeeLikeVideoVC ()
  13. @property (nonatomic, strong) ZFPlayerController *youpaipzFplayer;
  14. @property (nonatomic, strong) YOUPAIZFCustomControlView *youpaipcontrolView;
  15. @property (nonatomic, strong) UIImageView *youpaipcontainerView;
  16. @end
  17. @implementation YOUPAIZYSeeLikeVideoVC
  18. - (UIStatusBarStyle)preferredStatusBarStyle{
  19. return UIStatusBarStyleLightContent;
  20. }
  21. -(void)viewWillAppear:(BOOL)animated
  22. {
  23. [super viewWillAppear:animated];
  24. [self.navigationController.navigationBar setClearBar];
  25. self.youpaipzFplayer.viewControllerDisappear = NO;
  26. }
  27. -(void)viewWillDisappear:(BOOL)animated
  28. {
  29. [super viewWillDisappear:animated];
  30. [self.navigationController.navigationBar setDefaultBar];
  31. self.youpaipzFplayer.viewControllerDisappear = YES;
  32. }
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackClick) image:[UIImage imageNamed:@"vqu_images_nav_return_white"]];
  36. // self.zFplayer.assetURL =[NSURL URLWithString:self.mp4Url];
  37. [self.view addSubview:self.youpaipcontainerView];
  38. ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
  39. /// 播放器相关
  40. self.youpaipzFplayer = [ZFPlayerController playerWithPlayerManager:playerManager containerView:self.youpaipcontainerView];
  41. self.youpaipzFplayer.controlView = self.youpaipcontrolView;
  42. /// 设置退到后台继续播放
  43. self.youpaipzFplayer.pauseWhenAppResignActive = NO;
  44. /// 播放完成
  45. @weakify(self);
  46. self.youpaipzFplayer.playerDidToEnd = ^(id _Nonnull asset) {
  47. @strongify(self);
  48. [self.youpaipzFplayer.currentPlayerManager replay];
  49. [self.youpaipzFplayer playTheNext];
  50. if (!self.youpaipzFplayer.isLastAssetURL) {
  51. [self.youpaipcontrolView showTitle:@"" coverURLString:self.youpaipvideoLikesModel.youpaipcover_url fullScreenMode:ZFFullScreenModeLandscape];
  52. } else {
  53. [self.youpaipzFplayer stop];
  54. }
  55. };
  56. playerManager.assetURL = [NSURL URLWithString:self.youpaipvideoLikesModel.youpaipfile_url];
  57. }
  58. - (void)youpaifbackClick{
  59. [self.navigationController popViewControllerAnimated:YES];
  60. }
  61. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  62. if (self.youpaipzFplayer.isFullScreen) {
  63. return UIInterfaceOrientationMaskLandscape;
  64. }
  65. return UIInterfaceOrientationMaskPortrait;
  66. }
  67. - (YOUPAIZFCustomControlView *)youpaipcontrolView {
  68. if (!_youpaipcontrolView) {
  69. _youpaipcontrolView = [YOUPAIZFCustomControlView new];
  70. }
  71. return _youpaipcontrolView;
  72. }
  73. - (UIImageView *)youpaipcontainerView {
  74. if (!_youpaipcontainerView) {
  75. _youpaipcontainerView = [[UIImageView alloc] initWithFrame:self.view.bounds];
  76. [_youpaipcontainerView sd_setImageWithURL:[NSURL URLWithString:self.youpaipvideoLikesModel.youpaipcover_url]];
  77. }
  78. return _youpaipcontainerView;
  79. }
  80. @end