videoPlayByAVPlayerViewController.m 26 KB

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