123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801 |
- //
- // videoPlayByAVPlayerViewController.m
- // Private-X
- //
- // Created by xd h on 2024/5/22.
- //
- #import "videoPlayByAVPlayerViewController.h"
- #import "previewVideoPortraitTopMoreView.h"
- #import "editShareView.h"
- #import "uploadFileRecordViewController.h"
- #import "previewVideoLandscapeTopMoreView.h"
- #import "UIInterface+HXRotation.h"
- //#import <ZFPlayer/ZFAVPlayerManager.h>
- //#import <ZFPlayer/ZFIJKPlayerManager.h>
- //#import <ZFPlayer/ZFPlayerControlView.h>
- //#import <ZFPlayer/ZFPlayerConst.h>
- //#import "ZFUtilities.h"
- #import "ZFAVPlayerManager.h"
- #import "ZFIJKPlayerManager.h"
- #import "ZFPlayerControlView.h"
- #import "ZFPlayerConst.h"
- #import "ZFUtilities.h"
- #import "lastFileManager.h"
- #import "DFPlayer.h"
- @interface videoPlayByAVPlayerViewController ()
- @property (nonatomic, strong) ZFPlayerController *player;
- @property (nonatomic, strong) ZFPlayerControlView *controlView;
- @property (nonatomic, strong)ZFAVPlayerManager *playerManager;
- @property (nonatomic, strong)UIView *bgView;
- @property (nonatomic, strong)UIButton *portraitBackBtn;
- @property (nonatomic, strong)UIButton *portraitToLandScapeBtn;
- @property (nonatomic, strong)UIButton *portraitTopMoreBtn;
- @property (nonatomic, strong)previewVideoPortraitTopMoreView *previewVideoPortraitTopMoreV;
- @property (nonatomic, strong)UIButton *landScapeToPortraitBtn;
- @property (nonatomic, strong)UIButton *landScapeTopMoreBtn;
- @property (nonatomic, strong)previewVideoLandscapeTopMoreView *previewVideoLandscapeTopMoreV;
- @property(nonatomic,strong) editShareView *editShareV;
- @property(nonatomic,assign) BOOL isPortraitType;//竖屏状态
- @property(nonatomic,assign) BOOL isCodeSuspendAudioType;//手动暂停播放音乐
- @property(nonatomic,assign) BOOL isCodeSuspendVideoType;//手动暂停播放视频
- @property(nonatomic,assign) BOOL didHandleRotateingType;//是否正在处理旋转
- @end
- @implementation videoPlayByAVPlayerViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:YES];
- //self.navBarBGView.backgroundColor = [UIColor blackColor];
-
- self.view.backgroundColor = [UIColor blackColor];
- _isPortraitType = YES;
-
- //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDeviceOrientationChange) name:UIDeviceOrientationDidChangeNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInputPwdOkFun) name:didInputPWDNotification object:nil];
-
- _bgView = [[UIView alloc] init];
- [self.view addSubview:_bgView];
-
- [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-safeArea);
- make.top.mas_equalTo(H_STATE_BAR);
- }];
-
- @zf_weakify(self)
- self.controlView.backBtnClickCallback = ^{
- @zf_strongify(self)
- [self didClickBackBtnFun];
- };
-
- _playerManager = [[ZFAVPlayerManager alloc] init];
- /// 播放器相关
- self.player = [[ZFPlayerController alloc] initWithPlayerManager:_playerManager containerView:_bgView];
- self.player.controlView = self.controlView;
- //self.player.allowOrentitaionRotation = NO;
-
- // self.player.orientationObserver.supportInterfaceOrientation = ZFInterfaceOrientationMaskLandscape;
- // [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:nil];
-
- self.playerManager.playerPlayFailed = ^(id<ZFPlayerMediaPlayback> _Nonnull asset, id _Nonnull error) {
- mainBlock(^{
- @zf_strongify(self)
- self.controlView.failBtn.hidden = YES;
- [[iToast makeText:NSLocalizedString(@"play_video_fail_tip",nil)] show];
- });
-
- };
-
- self.playerManager.playerReadyToPlay = ^(id<ZFPlayerMediaPlayback> _Nonnull asset, NSURL * _Nonnull assetURL) {
- @zf_strongify(self)
- [self videoPlayerDidFun];
- };
-
- self.playerManager.playerDidToEnd = ^(id<ZFPlayerMediaPlayback> _Nonnull asset) {
- @zf_strongify(self)
- [self playerDidToEndFun];
- };
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:4 withEventValue:@"Video_preview"];
-
- if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
- ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
- _isCodeSuspendAudioType = YES;
- [[DFPlayer sharedPlayer] df_pause];
- }
- }
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
-
- if(!self.playerManager.assetURL){
- NSString *filePath = _VideoDataMode.path;
- NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
- NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
-
- // NSString *string = filePath;
- // NSString *filePathBase64 = [iTools base64UrlEncoder:string];
- // NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
-
- NSString *showUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
- HLog(@"video url:%@",fileUrl);
- //fileUrl = @"http://transfertest.armclouding.com:10010/getFile?path=/sdcard/bb.mp4";
-
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/123.mp4";//可以播放
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/movTest.mov";//可以播放
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/yinwei4.mp4";//可以播放
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/fuchouzhe2.mp4";//可以播放
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/fuchouzhe.m4v";//可以播放
-
- //fileUrl = @"http://file.phone.androidscloud.com:8210/document/newFile/download/1/ikIm5C0KjKNvusTF6tIH/LowLevelMultipartUpload_45050149837826456388";//可以播放
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/我的视频.mp4";
-
- fileUrl = [fileUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- showUrl = [showUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- //HLog(@"video url:%@",fileUrl);
-
- NSURL * sourceMovieURL= [NSURL URLWithString:fileUrl];
-
- self.playerManager.assetURL = sourceMovieURL;
-
- [self.controlView showTitle:_VideoDataMode.name coverURLString:showUrl fullScreenMode:ZFFullScreenModeAutomatic];
-
- [self customControlViewUIFun];
- }
-
- //开始生成 设备旋转 通知
- [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
- //添加 设备旋转 通知
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientChangeFun) name:UIDeviceOrientationDidChangeNotification object:nil];
-
- if(_isCodeSuspendVideoType){
- [self.player.currentPlayerManager play];
- }
-
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDarkContent];
-
- //销毁 设备旋转 通知
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:UIDeviceOrientationDidChangeNotification
- object:nil];
-
- //结束 设备旋转通知
- [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
-
- if(_controlView.portraitControlView.playOrPauseBtn.selected
- ||_controlView.landScapeControlView.playOrPauseBtn.selected)
- {
- [self.player.currentPlayerManager pause];
- _isCodeSuspendVideoType = YES;
- }
-
- //切换到竖屏
- [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
- }
- - (BOOL)shouldAutorotate {
- return NO;
- }
- /**屏幕旋转的通知回调*/
- - (void)orientChangeFun {
-
- UIDeviceOrientation orient = [UIDevice currentDevice].orientation;
-
- HLog(@"orientChangeFun :%d--%ld",_didHandleRotateingType,orient)
- if(_didHandleRotateingType){
- return;
- }
-
- KWeakSelf
- switch (orient) {
- case UIDeviceOrientationPortrait:
- HLog(@"竖直屏幕");
- if(!_isPortraitType){
- _didHandleRotateingType = YES;
- [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
- [weakSelf screenLandscapeToPortraitFun];
- }];
- }
- break;
- case UIDeviceOrientationLandscapeLeft:
- HLog(@"手机左转");
- if(_isPortraitType){
- _didHandleRotateingType = YES;
- [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:^{
- [weakSelf screenPortraitToLandscapeFun];
- }];
- }
-
- break;
- case UIDeviceOrientationPortraitUpsideDown:
- // NSLog(@"手机竖直");
- break;
- case UIDeviceOrientationLandscapeRight:
- HLog(@"手机右转");
- if(_isPortraitType){
- _didHandleRotateingType = YES;
- [self.player rotateToOrientation:UIInterfaceOrientationLandscapeLeft animated:NO completion:^{
- [weakSelf screenPortraitToLandscapeFun];
- }];
- }
- break;
- case UIDeviceOrientationUnknown:
- //NSLog(@"未知");
- break;
- case UIDeviceOrientationFaceUp:
- //NSLog(@"手机屏幕朝上");
- break;
- case UIDeviceOrientationFaceDown:
- //NSLog(@"手机屏幕朝下");
- break;
- default:
- break;
- }
- }
- - (void)handleDeviceOrientationChange
- {
- [self orientChangeFun];
- }
- #pragma mark 竖屏转横屏
- - (void)screenPortraitToLandscapeFun{
- _isPortraitType = NO;
- _didHandleRotateingType = NO;
-
- if(_editShareV.secretShareView)
- {
- [_controlView.landScapeControlView addSubview:_editShareV.secretShareView];
- [_editShareV.secretShareView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- _editShareV.isPortraitType = _isPortraitType;
- _editShareV.secretShareView.isPortraitType = _isPortraitType;
- return;
- }
-
- if(_editShareV){
- _editShareV.isPortraitType = _isPortraitType;
- [_controlView.landScapeControlView addSubview:_editShareV];
-
- [self->_editShareV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- }
- }
- #pragma mark 横屏转竖屏
- - (void)screenLandscapeToPortraitFun{
- _isPortraitType = YES;
- _didHandleRotateingType = NO;
-
- if(_editShareV.secretShareView)
- {
- [self.view addSubview:_editShareV.secretShareView];
-
- [_editShareV.secretShareView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- self->_editShareV.isPortraitType = self->_isPortraitType;
- self->_editShareV.secretShareView.isPortraitType = self->_isPortraitType;
-
- return;
- }
-
- if(_editShareV){
- _editShareV.isPortraitType = _isPortraitType;
- [self.view addSubview:_editShareV];
-
- [_editShareV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
- }
-
- }
- /// 如果不好用则copy VC中 加一下
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- if (self.player.isFullScreen) {
- return UIInterfaceOrientationMaskLandscape;
- }
- return UIInterfaceOrientationMaskPortrait;
- }
- //- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
- // return UIInterfaceOrientationLandscapeRight;
- //}
- - (ZFPlayerControlView *)controlView {
- if (!_controlView) {
- _controlView = [ZFPlayerControlView new];
- _controlView.fastViewAnimated = YES;
- _controlView.effectViewShow = NO;
- _controlView.prepareShowLoading = YES;
- //_controlView.showCustomStatusBar = YES;
-
- }
- return _controlView;
- }
- #pragma mark reset controlView UI
- - (void)customControlViewUIFun
- {
- //竖屏
- _controlView.portraitControlView.fullScreenBtn.hidden = YES;
- //totalTimeLabel slider
-
- //隐藏 缓存条
- // _controlView.bottomPgrogress.hidden = YES;
- // _controlView.fastProgressView.hidden = YES;
-
-
- UILabel *titleLab = _controlView.portraitControlView.titleLabel;
- titleLab.textAlignment = NSTextAlignmentCenter;
- titleLab.lineBreakMode = NSLineBreakByTruncatingMiddle;
- CGRect titleLabFrame = titleLab.frame;
- HLog(@"%f %f %f %f",titleLabFrame.origin.x,titleLabFrame.origin.y,titleLabFrame.size.width,titleLabFrame.size.height);
- HLog(@"");
-
- [titleLab mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(45);
- make.right.mas_equalTo(-80);
- make.height.mas_equalTo(titleLabFrame.size.height);
- make.top.mas_equalTo(titleLabFrame.origin.y);
- }];
-
- [_controlView.portraitControlView.topToolView addSubview:self.portraitBackBtn];
- [self.portraitBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- make.top.mas_equalTo(titleLabFrame.origin.y);
- }];
-
- [_controlView.portraitControlView.topToolView addSubview:self.portraitTopMoreBtn];
- [self.portraitTopMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-15);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- make.top.mas_equalTo(titleLabFrame.origin.y);
- }];
-
- [_controlView.portraitControlView.topToolView addSubview:self.portraitToLandScapeBtn];
- [self.portraitToLandScapeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.portraitTopMoreBtn.mas_left).offset(-10);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- make.top.mas_equalTo(titleLabFrame.origin.y);
- }];
-
- /*************************************************************************/
-
- //横屏
- //_controlView.landScapeControlView.fullScreenBtn.hidden = YES;
-
- //[_controlView.landScapeControlView.backBtn addTarget:self action:@selector(didClickBackBtnFun) forControlEvents:UIControlEventTouchUpInside];
-
- UILabel *titleLabInlandScape = _controlView.landScapeControlView.titleLabel;
- titleLabInlandScape.textAlignment = NSTextAlignmentCenter;
- titleLabInlandScape.lineBreakMode = NSLineBreakByTruncatingMiddle;
- //CGRect titleLabFrameInlandScape = titleLabInlandScape.frame;
- //titleLabInlandScape.backgroundColor = [UIColor greenColor];
-
- [titleLabInlandScape mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_controlView.landScapeControlView.backBtn.mas_right).offset(10);
- //make.right.mas_equalTo(-45);
- make.right.mas_equalTo(-25 -90);
- //make.height.mas_equalTo(titleLabFrameInlandScape.size.height);
- make.top.equalTo(_controlView.landScapeControlView.backBtn.mas_top).offset(0);
- make.bottom.equalTo(_controlView.landScapeControlView.backBtn.mas_bottom).offset(0);
- }];
-
- [_controlView.landScapeControlView.topToolView addSubview:self.landScapeTopMoreBtn];
- [self.landScapeTopMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-15 - 20);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- //make.top.mas_equalTo(titleLabFrame.origin.y);
- make.centerY.equalTo(_controlView.landScapeControlView.backBtn.mas_centerY).offset(0);
- }];
-
- [_controlView.landScapeControlView.topToolView addSubview:self.landScapeToPortraitBtn];
- [self.landScapeToPortraitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- //make.right.mas_equalTo(-15);
- make.right.equalTo(self.landScapeTopMoreBtn.mas_left).offset(-20);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- //make.top.mas_equalTo(titleLabFrame.origin.y);
- make.centerY.equalTo(_controlView.landScapeControlView.backBtn.mas_centerY).offset(0);
- }];
- }
- - (UIButton *)portraitBackBtn {
- if (!_portraitBackBtn) {
- _portraitBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_portraitBackBtn setImage:ZFPlayer_Image(@"ZFPlayer_back_full") forState:UIControlStateNormal];
- [_portraitBackBtn addTarget:self action:@selector(didClickBackBtnFun) forControlEvents:UIControlEventTouchUpInside];
- }
- return _portraitBackBtn;
- }
- - (UIButton *)portraitToLandScapeBtn {
- if (!_portraitToLandScapeBtn) {
- _portraitToLandScapeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_portraitToLandScapeBtn setImage:[UIImage imageNamed:@"portraitFullScreen_icon"] forState:UIControlStateNormal];
- [_portraitToLandScapeBtn addTarget:self action:@selector(portraitOrLandScapeFun:) forControlEvents:UIControlEventTouchUpInside];
- //_portraitToLandScapeBtn.backgroundColor = [UIColor greenColor];
- }
- return _portraitToLandScapeBtn;
- }
- - (UIButton*)portraitTopMoreBtn{
- if (!_portraitTopMoreBtn) {
- _portraitTopMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_portraitTopMoreBtn setImage:[UIImage imageNamed:@"nas_preview_more_white"] forState:UIControlStateNormal];
- [_portraitTopMoreBtn addTarget:self action:@selector(didClickMoreButFun:) forControlEvents:UIControlEventTouchUpInside];
- //_portraitTopMoreBtn.backgroundColor = [UIColor greenColor];
- }
- return _portraitTopMoreBtn;
- }
- - (UIButton *)landScapeToPortraitBtn {
- if (!_landScapeToPortraitBtn) {
- _landScapeToPortraitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_landScapeToPortraitBtn setImage:[UIImage imageNamed:@"landScapeToPortrait_icon"] forState:UIControlStateNormal];
- [_landScapeToPortraitBtn addTarget:self action:@selector(portraitOrLandScapeFun:) forControlEvents:UIControlEventTouchUpInside];
- //_portraitToLandScapeBtn.backgroundColor = [UIColor greenColor];
- }
- return _landScapeToPortraitBtn;
- }
- - (UIButton*)landScapeTopMoreBtn{
- if (!_landScapeTopMoreBtn) {
- _landScapeTopMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_landScapeTopMoreBtn setImage:[UIImage imageNamed:@"nas_preview_more_white"] forState:UIControlStateNormal];
- [_landScapeTopMoreBtn addTarget:self action:@selector(didClickMoreButFun:) forControlEvents:UIControlEventTouchUpInside];
- //_portraitTopMoreBtn.backgroundColor = [UIColor greenColor];
- }
- return _landScapeTopMoreBtn;
- }
- #pragma mark 点击返回键
- - (void)didClickBackBtnFun
- {
- [self.player stop];
-
- //_didClickBackType = YES;
-
- if(_isCodeSuspendAudioType){
- [[DFPlayer sharedPlayer] df_play];
- }
-
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark 横竖屏切换
- - (void)portraitOrLandScapeFun:(UIButton*)but
- {
- if(but ==_portraitToLandScapeBtn){
- //[self.player enterFullScreen:YES animated:YES];;
- [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:YES completion:nil];
- }
- else{
- [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:YES completion:nil];
- }
- }
- #pragma mark 点击顶部更多 获取 分享 下载 更多
- - (void)didClickMoreButFun:(UIButton*)but
- {
- if(but ==_portraitTopMoreBtn){
- _previewVideoPortraitTopMoreV = [[previewVideoPortraitTopMoreView alloc] init];
- [self.view addSubview:_previewVideoPortraitTopMoreV];
-
- [_previewVideoPortraitTopMoreV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- KWeakSelf
- _previewVideoPortraitTopMoreV.didClickButtonFun = ^(NSInteger tag) {
- if(tag == 10){
- [weakSelf gotoShareViewFun:NO];
- }
- else if (tag == 11){
- [weakSelf gotoDownLoadFileFun:NO];
- }
- else if (tag == 12){
- [weakSelf showDeleteAlearViewFun];
- }
- };
- }
- else{
-
- _previewVideoLandscapeTopMoreV = [[previewVideoLandscapeTopMoreView alloc] init];
- [_controlView.landScapeControlView addSubview:_previewVideoLandscapeTopMoreV];
-
- [_previewVideoLandscapeTopMoreV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- KWeakSelf
- _previewVideoLandscapeTopMoreV.didClickButtonFun = ^(NSInteger tag) {
- if(tag == 10){
- [weakSelf gotoShareViewFun:YES];
- }
- else if (tag == 11){
- [weakSelf gotoDownLoadFileFun:YES];
- }
- else if (tag == 12){
- [weakSelf didClickDeleteInLandscapeFun];
- }
- };
-
-
- }
-
- }
- #pragma mark 横屏点击删除
- - (void)didClickDeleteInLandscapeFun
- {
- //横屏的删除 要转竖屏
- // [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
- // [self screenLandscapeToPortraitFun];
- // [self showDeleteAlearViewFun];
- // }];
-
- //修复iOS15 bug
- [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
- }];
-
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf screenLandscapeToPortraitFun];
- [weakSelf showDeleteAlearViewFun];
- });
- }
- #pragma mark 视频可以播放 加入最近文件
- - (void)videoPlayerDidFun{
-
- NASFileAndFolderDataModel *dataModel = _VideoDataMode;
-
- lastFileModel *lastFileMod = [lastFileModel new];
- lastFileMod.path = dataModel.path;
- lastFileMod.name = dataModel.name;
- lastFileMod.time = dataModel.time;
- lastFileMod.size = dataModel.size;
- lastFileMod.duration = dataModel.duration;
- lastFileMod.type = @"video";
- lastFileMod.lastPreTime = [iTools getNowTimeStamp];
-
- [[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
-
- }
- #pragma mark 用户点击分享
- - (void)gotoShareViewFun:(BOOL)isLandscapeType
- {
- if(!_VideoDataMode){
- return;
- }
-
- if(isLandscapeType){//强制竖屏
- //修复iOS15 bug
- [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
- }];
-
- isLandscapeType = NO;
- }
-
- _editShareV = [[editShareView alloc] init];
- _editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[_VideoDataMode]];
- _editShareV.shareFileType = @"3";
- if(isLandscapeType){
- _editShareV.isPortraitType = NO;
- [_controlView.landScapeControlView addSubview:_editShareV];
- }
- else{
- _editShareV.isPortraitType = YES;
- [self.view addSubview:_editShareV];
- }
-
-
- [_editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- KWeakSelf
- _editShareV.didClickCloseFun = ^{
- [weakSelf clearShareAboutViewFun];
- };
- }
- #pragma mark 清理分享相关页面
- - (void)clearShareAboutViewFun
- {
- if(_editShareV.secretShareView){
- _editShareV.secretShareView = nil;
- }
-
- _editShareV = nil;
- }
- #pragma mark 删除视频
- - (void)showDeleteAlearViewFun
- {
- NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
- NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
- KWeakSelf
- ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
- msg:tipStr
- imageStr:nil
- cancelTitle:NSLocalizedString(@"other_cancel",nil)
- okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
- didClickOk:^{
-
- [weakSelf delFileListFun];
- } didClickCancel:^{
-
- }];
-
- curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:curAlretVC animated:YES completion:^{
- curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- #pragma mark 删除文件数据
- - (void)delFileListFun
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- if(_VideoDataMode){
- NSArray *pathArr = @[_VideoDataMode.path];
- [paraDict setValue:pathArr forKey:@"path"];
- }
-
- [self showNewIndicatorWithCanBack:YES canTouch:NO];
-
- //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
- KWeakSelf //@"delFile"
- [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
- [weakSelf removeNewIndicator];
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
-
- [weakSelf didDeleteSucFun:self->_VideoDataMode.path];
- }
- else{
-
- }
- } failure:^(NSError * _Nonnull error) {
- [weakSelf removeNewIndicator];
- }];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
- }
- #pragma mark 删除成功
- - (void)didDeleteSucFun:(NSString*)path
- {
- //1.删除最近文件数据
- [[lastFileManager shareManager] deleteFileInfoWithUrl:path];
-
- if(_didNeedDeleteFile){
- _didNeedDeleteFile(path);
- }
-
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark 去下载文件
- - (void)gotoDownLoadFileFun:(BOOL)isLandscapeType
- {
- if(_VideoDataMode){
-
- if(isLandscapeType){
- //切换到竖屏
- //[self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
- [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:YES completion:nil];
- }
-
- couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
- fileModel.fileType = _VideoDataMode.type;
- fileModel.path = _VideoDataMode.path;
- fileModel.name = _VideoDataMode.name;
- fileModel.length = _VideoDataMode.size;
-
- NSMutableArray *arr = [NSMutableArray new];
- [arr addObject:fileModel];
-
- //切换到竖屏
- [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
-
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isDownloadingType = YES;
- [vc gotoDownloadFile:arr];
- }
- }
- #pragma mark 输入完密码
- - (void)didInputPwdOkFun
- {
- if(ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
- if(self.player.pauseByEvent){//隐私模式 是
- self.player.pauseByEvent = NO;
- }
- }
- }
- #pragma mark 播放完成
- - (void)playerDidToEndFun
- {
- KWeakSelf
- [self.player seekToTime:0 completionHandler:^(BOOL finished) {
- [weakSelf.playerManager pause];
- [weakSelf.controlView.portraitControlView playBtnSelectedState:NO];
- [weakSelf.controlView.landScapeControlView playBtnSelectedState:NO];
- }];
-
- }
- @end
|