// // YOUPAIZYSeeLikeVideoVC.m // MEISHI // // Created by Elaine on 2021/2/3. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAIZYSeeLikeVideoVC.h" #import "ZFPlayer.h" #import "ZFAVPlayerManager.h" #import "YOUPAIZFCustomControlView.h" @interface YOUPAIZYSeeLikeVideoVC () @property (nonatomic, strong) ZFPlayerController *youpaipzFplayer; @property (nonatomic, strong) YOUPAIZFCustomControlView *youpaipcontrolView; @property (nonatomic, strong) UIImageView *youpaipcontainerView; @end @implementation YOUPAIZYSeeLikeVideoVC - (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController.navigationBar setClearBar]; self.youpaipzFplayer.viewControllerDisappear = NO; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController.navigationBar setDefaultBar]; self.youpaipzFplayer.viewControllerDisappear = YES; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackClick) image:[UIImage imageNamed:@"vqu_images_nav_return_white"]]; // self.zFplayer.assetURL =[NSURL URLWithString:self.mp4Url]; [self.view addSubview:self.youpaipcontainerView]; ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init]; /// 播放器相关 self.youpaipzFplayer = [ZFPlayerController playerWithPlayerManager:playerManager containerView:self.youpaipcontainerView]; self.youpaipzFplayer.controlView = self.youpaipcontrolView; /// 设置退到后台继续播放 self.youpaipzFplayer.pauseWhenAppResignActive = NO; /// 播放完成 @weakify(self); self.youpaipzFplayer.playerDidToEnd = ^(id _Nonnull asset) { @strongify(self); [self.youpaipzFplayer.currentPlayerManager replay]; [self.youpaipzFplayer playTheNext]; if (!self.youpaipzFplayer.isLastAssetURL) { [self.youpaipcontrolView showTitle:@"" coverURLString:self.youpaipvideoLikesModel.youpaipcover_url fullScreenMode:ZFFullScreenModeLandscape]; } else { [self.youpaipzFplayer stop]; } }; playerManager.assetURL = [NSURL URLWithString:self.youpaipvideoLikesModel.youpaipfile_url]; } - (void)youpaifbackClick{ [self.navigationController popViewControllerAnimated:YES]; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { if (self.youpaipzFplayer.isFullScreen) { return UIInterfaceOrientationMaskLandscape; } return UIInterfaceOrientationMaskPortrait; } - (YOUPAIZFCustomControlView *)youpaipcontrolView { if (!_youpaipcontrolView) { _youpaipcontrolView = [YOUPAIZFCustomControlView new]; } return _youpaipcontrolView; } - (UIImageView *)youpaipcontainerView { if (!_youpaipcontainerView) { _youpaipcontainerView = [[UIImageView alloc] initWithFrame:self.view.bounds]; [_youpaipcontainerView sd_setImageWithURL:[NSURL URLWithString:self.youpaipvideoLikesModel.youpaipcover_url]]; } return _youpaipcontainerView; } @end