videoPlayByAVPlayerViewController.m 24 KB

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