videoPlayByAVPlayerViewController.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. //
  2. // videoPlayByAVPlayerViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/22.
  6. //
  7. #import "videoPlayByAVPlayerViewController.h"
  8. #import "previewVideoPortraitTopMoreView.h"
  9. #import "editShareView.h"
  10. #import "uploadFileRecordViewController.h"
  11. #import "previewVideoLandscapeTopMoreView.h"
  12. #import "UIInterface+HXRotation.h"
  13. //#import <ZFPlayer/ZFAVPlayerManager.h>
  14. //#import <ZFPlayer/ZFIJKPlayerManager.h>
  15. //#import <ZFPlayer/ZFPlayerControlView.h>
  16. //#import <ZFPlayer/ZFPlayerConst.h>
  17. //#import "ZFUtilities.h"
  18. #import "ZFAVPlayerManager.h"
  19. #import "ZFIJKPlayerManager.h"
  20. #import "ZFPlayerControlView.h"
  21. #import "ZFPlayerConst.h"
  22. #import "ZFUtilities.h"
  23. #import "lastFileManager.h"
  24. #import "DFPlayer.h"
  25. @interface videoPlayByAVPlayerViewController ()
  26. @property (nonatomic, strong) ZFPlayerController *player;
  27. @property (nonatomic, strong) ZFPlayerControlView *controlView;
  28. @property (nonatomic, strong)ZFAVPlayerManager *playerManager;
  29. @property (nonatomic, strong)UIView *bgView;
  30. @property (nonatomic, strong)UIButton *portraitBackBtn;
  31. @property (nonatomic, strong)UIButton *portraitToLandScapeBtn;
  32. @property (nonatomic, strong)UIButton *portraitTopMoreBtn;
  33. @property (nonatomic, strong)previewVideoPortraitTopMoreView *previewVideoPortraitTopMoreV;
  34. @property (nonatomic, strong)UIButton *landScapeToPortraitBtn;
  35. @property (nonatomic, strong)UIButton *landScapeTopMoreBtn;
  36. @property (nonatomic, strong)previewVideoLandscapeTopMoreView *previewVideoLandscapeTopMoreV;
  37. @property(nonatomic,strong) editShareView *editShareV;
  38. @property(nonatomic,assign) BOOL isPortraitType;//竖屏状态
  39. @property(nonatomic,assign) BOOL isCodeSuspendAudioType;//手动暂停播放音乐
  40. @property(nonatomic,assign) BOOL isCodeSuspendVideoType;//手动暂停播放视频
  41. @property(nonatomic,assign) BOOL didHandlePortraitType;//竖屏处理过了
  42. @end
  43. @implementation videoPlayByAVPlayerViewController
  44. - (void)viewDidLoad {
  45. [super viewDidLoad];
  46. [self.toolBar setHidden:YES];
  47. [self.navigationBar setHidden:YES];
  48. [self.navBarBGView setHidden:YES];
  49. //self.navBarBGView.backgroundColor = [UIColor blackColor];
  50. self.view.backgroundColor = [UIColor blackColor];
  51. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDeviceOrientationChange) name:UIDeviceOrientationDidChangeNotification object:nil];
  52. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInputPwdOkFun) name:didInputPWDNotification object:nil];
  53. _bgView = [[UIView alloc] init];
  54. [self.view addSubview:_bgView];
  55. [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.mas_equalTo(0);
  57. make.right.mas_equalTo(0);
  58. make.bottom.mas_equalTo(-safeArea);
  59. make.top.mas_equalTo(H_STATE_BAR);
  60. }];
  61. @zf_weakify(self)
  62. self.controlView.backBtnClickCallback = ^{
  63. @zf_strongify(self)
  64. [self didClickBackBtnFun];
  65. };
  66. _playerManager = [[ZFAVPlayerManager alloc] init];
  67. /// 播放器相关
  68. self.player = [[ZFPlayerController alloc] initWithPlayerManager:_playerManager containerView:_bgView];
  69. self.player.controlView = self.controlView;
  70. //self.player.allowOrentitaionRotation = NO;
  71. // self.player.orientationObserver.supportInterfaceOrientation = ZFInterfaceOrientationMaskLandscape;
  72. // [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:nil];
  73. self.playerManager.playerPlayFailed = ^(id<ZFPlayerMediaPlayback> _Nonnull asset, id _Nonnull error) {
  74. mainBlock(^{
  75. @zf_strongify(self)
  76. self.controlView.failBtn.hidden = YES;
  77. [[iToast makeText:NSLocalizedString(@"play_video_fail_tip",nil)] show];
  78. });
  79. };
  80. self.playerManager.playerReadyToPlay = ^(id<ZFPlayerMediaPlayback> _Nonnull asset, NSURL * _Nonnull assetURL) {
  81. @zf_strongify(self)
  82. [self videoPlayerDidFun];
  83. };
  84. //数据埋点
  85. [[netWorkManager shareInstance] DataEmbeddingPointBy:4 withEventValue:@"Video_preview"];
  86. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  87. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
  88. _isCodeSuspendAudioType = YES;
  89. [[DFPlayer sharedPlayer] df_pause];
  90. }
  91. }
  92. - (void)viewDidAppear:(BOOL)animated
  93. {
  94. [super viewDidAppear:animated];
  95. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  96. if(!self.playerManager.assetURL){
  97. NSString *filePath = _VideoDataMode.path;
  98. NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
  99. NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
  100. // NSString *string = filePath;
  101. // NSString *filePathBase64 = [iTools base64UrlEncoder:string];
  102. // NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
  103. NSString *showUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
  104. HLog(@"video url:%@",fileUrl);
  105. //fileUrl = @"http://transfertest.armclouding.com:10010/getFile?path=/sdcard/bb.mp4";
  106. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/123.mp4";//可以播放
  107. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/movTest.mov";//可以播放
  108. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/yinwei4.mp4";//可以播放
  109. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/fuchouzhe2.mp4";//可以播放
  110. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/fuchouzhe.m4v";//可以播放
  111. //fileUrl = @"http://file.phone.androidscloud.com:8210/document/newFile/download/1/ikIm5C0KjKNvusTF6tIH/LowLevelMultipartUpload_45050149837826456388";//可以播放
  112. //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/我的视频.mp4";
  113. fileUrl = [fileUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  114. showUrl = [showUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  115. //HLog(@"video url:%@",fileUrl);
  116. NSURL * sourceMovieURL= [NSURL URLWithString:fileUrl];
  117. self.playerManager.assetURL = sourceMovieURL;
  118. [self.controlView showTitle:_VideoDataMode.name coverURLString:showUrl fullScreenMode:ZFFullScreenModeAutomatic];
  119. [self customControlViewUIFun];
  120. }
  121. //开始生成 设备旋转 通知
  122. [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
  123. //添加 设备旋转 通知
  124. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientChangeFun) name:UIDeviceOrientationDidChangeNotification object:nil];
  125. if(_isCodeSuspendVideoType){
  126. [self.player.currentPlayerManager play];
  127. }
  128. }
  129. - (void)viewWillDisappear:(BOOL)animated {
  130. [super viewWillDisappear:animated];
  131. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDarkContent];
  132. //销毁 设备旋转 通知
  133. [[NSNotificationCenter defaultCenter] removeObserver:self
  134. name:UIDeviceOrientationDidChangeNotification
  135. object:nil];
  136. //结束 设备旋转通知
  137. [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
  138. if(_controlView.portraitControlView.playOrPauseBtn.selected
  139. ||_controlView.landScapeControlView.playOrPauseBtn.selected)
  140. {
  141. [self.player.currentPlayerManager pause];
  142. _isCodeSuspendVideoType = YES;
  143. }
  144. //切换到竖屏
  145. [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  146. }
  147. - (BOOL)shouldAutorotate {
  148. return NO;
  149. }
  150. /**屏幕旋转的通知回调*/
  151. - (void)orientChangeFun {
  152. UIDeviceOrientation orient = [UIDevice currentDevice].orientation;
  153. HLog(@"orientChangeFun :%d--%ld",_didHandlePortraitType,orient)
  154. if(_didHandlePortraitType && orient == UIDeviceOrientationPortrait){
  155. return;
  156. }
  157. _didHandlePortraitType = NO;
  158. switch (orient) {
  159. case UIDeviceOrientationPortrait:
  160. HLog(@"竖直屏幕");
  161. if(!_isPortraitType){
  162. [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
  163. [self screenLandscapeToPortraitFun];
  164. }];
  165. }
  166. _didHandlePortraitType = YES;
  167. break;
  168. case UIDeviceOrientationLandscapeLeft:
  169. HLog(@"手机左转");
  170. if(_isPortraitType){
  171. [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:^{
  172. [self screenPortraitToLandscapeFun];
  173. }];
  174. }
  175. break;
  176. case UIDeviceOrientationPortraitUpsideDown:
  177. // NSLog(@"手机竖直");
  178. break;
  179. case UIDeviceOrientationLandscapeRight:
  180. HLog(@"手机右转");
  181. if(_isPortraitType){
  182. [self.player rotateToOrientation:UIInterfaceOrientationLandscapeLeft animated:NO completion:^{
  183. [self screenPortraitToLandscapeFun];
  184. }];
  185. }
  186. break;
  187. case UIDeviceOrientationUnknown:
  188. //NSLog(@"未知");
  189. break;
  190. case UIDeviceOrientationFaceUp:
  191. //NSLog(@"手机屏幕朝上");
  192. break;
  193. case UIDeviceOrientationFaceDown:
  194. //NSLog(@"手机屏幕朝下");
  195. break;
  196. default:
  197. break;
  198. }
  199. }
  200. - (void)handleDeviceOrientationChange
  201. {
  202. [self orientChangeFun];
  203. }
  204. #pragma mark 竖屏转横屏
  205. - (void)screenPortraitToLandscapeFun{
  206. _isPortraitType = NO;
  207. if(_editShareV.secretShareView)
  208. {
  209. [_controlView.landScapeControlView addSubview:_editShareV.secretShareView];
  210. [_editShareV.secretShareView mas_remakeConstraints:^(MASConstraintMaker *make) {
  211. make.left.mas_equalTo(0);
  212. make.right.mas_equalTo(0);
  213. make.bottom.mas_equalTo(0);
  214. make.top.mas_equalTo(0);
  215. }];
  216. _editShareV.isPortraitType = _isPortraitType;
  217. _editShareV.secretShareView.isPortraitType = _isPortraitType;
  218. return;
  219. }
  220. if(_editShareV){
  221. _editShareV.isPortraitType = _isPortraitType;
  222. [_controlView.landScapeControlView addSubview:_editShareV];
  223. [self->_editShareV mas_remakeConstraints:^(MASConstraintMaker *make) {
  224. make.left.mas_equalTo(0);
  225. make.right.mas_equalTo(0);
  226. make.bottom.mas_equalTo(0);
  227. make.top.mas_equalTo(0);
  228. }];
  229. }
  230. }
  231. #pragma mark 横屏转竖屏
  232. - (void)screenLandscapeToPortraitFun{
  233. _isPortraitType = YES;
  234. if(_editShareV.secretShareView)
  235. {
  236. [self.view addSubview:_editShareV.secretShareView];
  237. [_editShareV.secretShareView mas_remakeConstraints:^(MASConstraintMaker *make) {
  238. make.left.mas_equalTo(0);
  239. make.right.mas_equalTo(0);
  240. make.bottom.mas_equalTo(0);
  241. make.top.mas_equalTo(0);
  242. }];
  243. self->_editShareV.isPortraitType = self->_isPortraitType;
  244. self->_editShareV.secretShareView.isPortraitType = self->_isPortraitType;
  245. return;
  246. }
  247. if(_editShareV){
  248. _editShareV.isPortraitType = _isPortraitType;
  249. [self.view addSubview:_editShareV];
  250. [_editShareV mas_remakeConstraints:^(MASConstraintMaker *make) {
  251. make.left.mas_equalTo(0);
  252. make.right.mas_equalTo(0);
  253. make.bottom.mas_equalTo(0);
  254. make.top.mas_equalTo(0);
  255. }];
  256. }
  257. }
  258. /// 如果不好用则copy VC中 加一下
  259. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  260. if (self.player.isFullScreen) {
  261. return UIInterfaceOrientationMaskLandscape;
  262. }
  263. return UIInterfaceOrientationMaskPortrait;
  264. }
  265. //- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
  266. // return UIInterfaceOrientationLandscapeRight;
  267. //}
  268. - (ZFPlayerControlView *)controlView {
  269. if (!_controlView) {
  270. _controlView = [ZFPlayerControlView new];
  271. _controlView.fastViewAnimated = YES;
  272. _controlView.effectViewShow = NO;
  273. _controlView.prepareShowLoading = YES;
  274. //_controlView.showCustomStatusBar = YES;
  275. }
  276. return _controlView;
  277. }
  278. #pragma mark reset controlView UI
  279. - (void)customControlViewUIFun
  280. {
  281. //竖屏
  282. _controlView.portraitControlView.fullScreenBtn.hidden = YES;
  283. //totalTimeLabel slider
  284. //隐藏 缓存条
  285. // _controlView.bottomPgrogress.hidden = YES;
  286. // _controlView.fastProgressView.hidden = YES;
  287. UILabel *titleLab = _controlView.portraitControlView.titleLabel;
  288. titleLab.textAlignment = NSTextAlignmentCenter;
  289. titleLab.lineBreakMode = NSLineBreakByTruncatingMiddle;
  290. CGRect titleLabFrame = titleLab.frame;
  291. HLog(@"%f %f %f %f",titleLabFrame.origin.x,titleLabFrame.origin.y,titleLabFrame.size.width,titleLabFrame.size.height);
  292. HLog(@"");
  293. [titleLab mas_remakeConstraints:^(MASConstraintMaker *make) {
  294. make.left.mas_equalTo(45);
  295. make.right.mas_equalTo(-45);
  296. make.height.mas_equalTo(titleLabFrame.size.height);
  297. make.top.mas_equalTo(titleLabFrame.origin.y);
  298. }];
  299. [_controlView.portraitControlView.topToolView addSubview:self.portraitBackBtn];
  300. [self.portraitBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  301. make.left.mas_equalTo(15);
  302. make.width.mas_equalTo(28);
  303. make.height.mas_equalTo(28);
  304. make.top.mas_equalTo(titleLabFrame.origin.y);
  305. }];
  306. [_controlView.portraitControlView.topToolView addSubview:self.portraitTopMoreBtn];
  307. [self.portraitTopMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  308. make.right.mas_equalTo(-15);
  309. make.width.mas_equalTo(28);
  310. make.height.mas_equalTo(28);
  311. make.top.mas_equalTo(titleLabFrame.origin.y);
  312. }];
  313. [_controlView.portraitControlView.topToolView addSubview:self.portraitToLandScapeBtn];
  314. [self.portraitToLandScapeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  315. make.right.equalTo(self.portraitTopMoreBtn.mas_left).offset(-10);
  316. make.width.mas_equalTo(28);
  317. make.height.mas_equalTo(28);
  318. make.top.mas_equalTo(titleLabFrame.origin.y);
  319. }];
  320. /*************************************************************************/
  321. //横屏
  322. //_controlView.landScapeControlView.fullScreenBtn.hidden = YES;
  323. //[_controlView.landScapeControlView.backBtn addTarget:self action:@selector(didClickBackBtnFun) forControlEvents:UIControlEventTouchUpInside];
  324. UILabel *titleLabInlandScape = _controlView.landScapeControlView.titleLabel;
  325. titleLabInlandScape.textAlignment = NSTextAlignmentCenter;
  326. titleLabInlandScape.lineBreakMode = NSLineBreakByTruncatingMiddle;
  327. //CGRect titleLabFrameInlandScape = titleLabInlandScape.frame;
  328. //titleLabInlandScape.backgroundColor = [UIColor greenColor];
  329. [titleLabInlandScape mas_remakeConstraints:^(MASConstraintMaker *make) {
  330. make.left.equalTo(_controlView.landScapeControlView.backBtn.mas_right).offset(10);
  331. //make.right.mas_equalTo(-45);
  332. make.right.mas_equalTo(-25 -90);
  333. //make.height.mas_equalTo(titleLabFrameInlandScape.size.height);
  334. make.top.equalTo(_controlView.landScapeControlView.backBtn.mas_top).offset(0);
  335. make.bottom.equalTo(_controlView.landScapeControlView.backBtn.mas_bottom).offset(0);
  336. }];
  337. [_controlView.landScapeControlView.topToolView addSubview:self.landScapeTopMoreBtn];
  338. [self.landScapeTopMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  339. make.right.mas_equalTo(-15 - 20);
  340. make.width.mas_equalTo(28);
  341. make.height.mas_equalTo(28);
  342. //make.top.mas_equalTo(titleLabFrame.origin.y);
  343. make.centerY.equalTo(_controlView.landScapeControlView.backBtn.mas_centerY).offset(0);
  344. }];
  345. [_controlView.landScapeControlView.topToolView addSubview:self.landScapeToPortraitBtn];
  346. [self.landScapeToPortraitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  347. //make.right.mas_equalTo(-15);
  348. make.right.equalTo(self.landScapeTopMoreBtn.mas_left).offset(-20);
  349. make.width.mas_equalTo(28);
  350. make.height.mas_equalTo(28);
  351. //make.top.mas_equalTo(titleLabFrame.origin.y);
  352. make.centerY.equalTo(_controlView.landScapeControlView.backBtn.mas_centerY).offset(0);
  353. }];
  354. }
  355. - (UIButton *)portraitBackBtn {
  356. if (!_portraitBackBtn) {
  357. _portraitBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  358. [_portraitBackBtn setImage:ZFPlayer_Image(@"ZFPlayer_back_full") forState:UIControlStateNormal];
  359. [_portraitBackBtn addTarget:self action:@selector(didClickBackBtnFun) forControlEvents:UIControlEventTouchUpInside];
  360. }
  361. return _portraitBackBtn;
  362. }
  363. - (UIButton *)portraitToLandScapeBtn {
  364. if (!_portraitToLandScapeBtn) {
  365. _portraitToLandScapeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  366. [_portraitToLandScapeBtn setImage:[UIImage imageNamed:@"portraitFullScreen_icon"] forState:UIControlStateNormal];
  367. [_portraitToLandScapeBtn addTarget:self action:@selector(portraitOrLandScapeFun:) forControlEvents:UIControlEventTouchUpInside];
  368. //_portraitToLandScapeBtn.backgroundColor = [UIColor greenColor];
  369. }
  370. return _portraitToLandScapeBtn;
  371. }
  372. - (UIButton*)portraitTopMoreBtn{
  373. if (!_portraitTopMoreBtn) {
  374. _portraitTopMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  375. [_portraitTopMoreBtn setImage:[UIImage imageNamed:@"nas_preview_more_white"] forState:UIControlStateNormal];
  376. [_portraitTopMoreBtn addTarget:self action:@selector(didClickMoreButFun:) forControlEvents:UIControlEventTouchUpInside];
  377. //_portraitTopMoreBtn.backgroundColor = [UIColor greenColor];
  378. }
  379. return _portraitTopMoreBtn;
  380. }
  381. - (UIButton *)landScapeToPortraitBtn {
  382. if (!_landScapeToPortraitBtn) {
  383. _landScapeToPortraitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  384. [_landScapeToPortraitBtn setImage:[UIImage imageNamed:@"landScapeToPortrait_icon"] forState:UIControlStateNormal];
  385. [_landScapeToPortraitBtn addTarget:self action:@selector(portraitOrLandScapeFun:) forControlEvents:UIControlEventTouchUpInside];
  386. //_portraitToLandScapeBtn.backgroundColor = [UIColor greenColor];
  387. }
  388. return _landScapeToPortraitBtn;
  389. }
  390. - (UIButton*)landScapeTopMoreBtn{
  391. if (!_landScapeTopMoreBtn) {
  392. _landScapeTopMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  393. [_landScapeTopMoreBtn setImage:[UIImage imageNamed:@"nas_preview_more_white"] forState:UIControlStateNormal];
  394. [_landScapeTopMoreBtn addTarget:self action:@selector(didClickMoreButFun:) forControlEvents:UIControlEventTouchUpInside];
  395. //_portraitTopMoreBtn.backgroundColor = [UIColor greenColor];
  396. }
  397. return _landScapeTopMoreBtn;
  398. }
  399. #pragma mark 点击返回键
  400. - (void)didClickBackBtnFun
  401. {
  402. [self.player stop];
  403. //_didClickBackType = YES;
  404. if(_isCodeSuspendAudioType){
  405. [[DFPlayer sharedPlayer] df_play];
  406. }
  407. [self.navigationController popViewControllerAnimated:YES];
  408. }
  409. #pragma mark 横竖屏切换
  410. - (void)portraitOrLandScapeFun:(UIButton*)but
  411. {
  412. if(but ==_portraitToLandScapeBtn){
  413. //[self.player enterFullScreen:YES animated:YES];;
  414. [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:YES completion:nil];
  415. }
  416. else{
  417. [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:YES completion:nil];
  418. }
  419. }
  420. #pragma mark 点击顶部更多 获取 分享 下载 更多
  421. - (void)didClickMoreButFun:(UIButton*)but
  422. {
  423. if(but ==_portraitTopMoreBtn){
  424. _previewVideoPortraitTopMoreV = [[previewVideoPortraitTopMoreView alloc] init];
  425. [self.view addSubview:_previewVideoPortraitTopMoreV];
  426. [_previewVideoPortraitTopMoreV mas_makeConstraints:^(MASConstraintMaker *make) {
  427. make.left.mas_equalTo(0);
  428. make.right.mas_equalTo(0);
  429. make.bottom.mas_equalTo(0);
  430. make.top.mas_equalTo(0);
  431. }];
  432. KWeakSelf
  433. _previewVideoPortraitTopMoreV.didClickButtonFun = ^(NSInteger tag) {
  434. if(tag == 10){
  435. [weakSelf gotoShareViewFun:NO];
  436. }
  437. else if (tag == 11){
  438. [weakSelf gotoDownLoadFileFun:NO];
  439. }
  440. else if (tag == 12){
  441. [weakSelf showDeleteAlearViewFun];
  442. }
  443. };
  444. }
  445. else{
  446. _previewVideoLandscapeTopMoreV = [[previewVideoLandscapeTopMoreView alloc] init];
  447. [_controlView.landScapeControlView addSubview:_previewVideoLandscapeTopMoreV];
  448. [_previewVideoLandscapeTopMoreV mas_makeConstraints:^(MASConstraintMaker *make) {
  449. make.left.mas_equalTo(0);
  450. make.right.mas_equalTo(0);
  451. make.bottom.mas_equalTo(0);
  452. make.top.mas_equalTo(0);
  453. }];
  454. KWeakSelf
  455. _previewVideoLandscapeTopMoreV.didClickButtonFun = ^(NSInteger tag) {
  456. if(tag == 10){
  457. [weakSelf gotoShareViewFun:YES];
  458. }
  459. else if (tag == 11){
  460. [weakSelf gotoDownLoadFileFun:YES];
  461. }
  462. else if (tag == 12){
  463. [weakSelf didClickDeleteInLandscapeFun];
  464. }
  465. };
  466. }
  467. }
  468. #pragma mark 横屏点击删除
  469. - (void)didClickDeleteInLandscapeFun
  470. {
  471. //横屏的删除 要转竖屏
  472. [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
  473. [self screenLandscapeToPortraitFun];
  474. [self showDeleteAlearViewFun];
  475. }];
  476. }
  477. #pragma mark 视频可以播放 加入最近文件
  478. - (void)videoPlayerDidFun{
  479. NASFileAndFolderDataModel *dataModel = _VideoDataMode;
  480. lastFileModel *lastFileMod = [lastFileModel new];
  481. lastFileMod.path = dataModel.path;
  482. lastFileMod.name = dataModel.name;
  483. lastFileMod.time = dataModel.time;
  484. lastFileMod.size = dataModel.size;
  485. lastFileMod.duration = dataModel.duration;
  486. lastFileMod.type = @"video";
  487. lastFileMod.lastPreTime = [iTools getNowTimeStamp];
  488. [[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
  489. }
  490. #pragma mark 用户点击分享
  491. - (void)gotoShareViewFun:(BOOL)isLandscapeType
  492. {
  493. if(!_VideoDataMode){
  494. return;
  495. }
  496. _editShareV = [[editShareView alloc] init];
  497. _editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[_VideoDataMode]];
  498. _editShareV.shareFileType = @"3";
  499. if(isLandscapeType){
  500. _editShareV.isPortraitType = NO;
  501. [_controlView.landScapeControlView addSubview:_editShareV];
  502. }
  503. else{
  504. _editShareV.isPortraitType = YES;
  505. [self.view addSubview:_editShareV];
  506. }
  507. [_editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  508. make.left.mas_equalTo(0);
  509. make.right.mas_equalTo(0);
  510. make.bottom.mas_equalTo(0);
  511. make.top.mas_equalTo(0);
  512. }];
  513. }
  514. #pragma mark 删除图片
  515. - (void)showDeleteAlearViewFun
  516. {
  517. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  518. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  519. KWeakSelf
  520. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  521. msg:tipStr
  522. imageStr:nil
  523. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  524. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  525. didClickOk:^{
  526. [weakSelf delFileListFun];
  527. } didClickCancel:^{
  528. }];
  529. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  530. [self presentViewController:curAlretVC animated:YES completion:^{
  531. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  532. }];
  533. }
  534. #pragma mark 删除文件数据
  535. - (void)delFileListFun
  536. {
  537. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  538. if(_VideoDataMode){
  539. NSArray *pathArr = @[_VideoDataMode.path];
  540. [paraDict setValue:pathArr forKey:@"path"];
  541. }
  542. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  543. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  544. KWeakSelf //@"delFile"
  545. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  546. [weakSelf removeNewIndicator];
  547. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  548. if(model && model.status == 0){
  549. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  550. [weakSelf didDeleteSucFun:self->_VideoDataMode.path];
  551. }
  552. else{
  553. }
  554. } failure:^(NSError * _Nonnull error) {
  555. [weakSelf removeNewIndicator];
  556. }];
  557. //数据埋点
  558. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  559. }
  560. #pragma mark 删除成功
  561. - (void)didDeleteSucFun:(NSString*)path
  562. {
  563. //1.删除最近文件数据
  564. [[lastFileManager shareManager] deleteFileInfoWithUrl:path];
  565. if(_didNeedToRegetDataFun){
  566. _didNeedToRegetDataFun();
  567. }
  568. [self.navigationController popViewControllerAnimated:YES];
  569. }
  570. #pragma mark 去下载文件
  571. - (void)gotoDownLoadFileFun:(BOOL)isLandscapeType
  572. {
  573. if(_VideoDataMode){
  574. if(isLandscapeType){
  575. //切换到竖屏
  576. //[self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  577. [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:YES completion:nil];
  578. }
  579. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  580. fileModel.fileType = _VideoDataMode.type;
  581. fileModel.path = _VideoDataMode.path;
  582. fileModel.name = _VideoDataMode.name;
  583. fileModel.length = _VideoDataMode.size;
  584. NSMutableArray *arr = [NSMutableArray new];
  585. [arr addObject:fileModel];
  586. //切换到竖屏
  587. [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  588. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  589. [self.navigationController pushViewController:vc animated:YES];
  590. vc.isDownloadingType = YES;
  591. [vc gotoDownloadFile:arr];
  592. }
  593. }
  594. #pragma mark 输入完密码
  595. - (void)didInputPwdOkFun
  596. {
  597. if([connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode){
  598. if(self.player.pauseByEvent){//隐私模式 是
  599. self.player.pauseByEvent = NO;
  600. }
  601. }
  602. }
  603. @end