videoPlayByAVPlayerViewController.m 25 KB

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