浏览代码

1.视频进行预览和最近文件进行播放视频,视频横屏播放点击返回按钮应用闪退 (ios 15)

huangxiaodong 11 月之前
父节点
当前提交
74772e7bc0

+ 17 - 8
创维盒子/双子星云手机/Class/Set/previewFile/videoPlayByAVPlayerViewController.m

@@ -46,6 +46,7 @@
 @property(nonatomic,assign) BOOL isPortraitType;//竖屏状态
 @property(nonatomic,assign) BOOL isCodeSuspendAudioType;//手动暂停播放音乐
 @property(nonatomic,assign) BOOL isCodeSuspendVideoType;//手动暂停播放视频
+@property(nonatomic,assign) BOOL didHandlePortraitType;//竖屏处理过了
 @end
 
 @implementation videoPlayByAVPlayerViewController
@@ -73,9 +74,6 @@
     self.controlView.backBtnClickCallback = ^{
         @zf_strongify(self)
         [self didClickBackBtnFun];
-//        [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:nil];
-//        [self.player stop];
-        //[self dismissViewControllerAnimated:NO completion:nil];
     };
     
     _playerManager = [[ZFAVPlayerManager alloc] init];
@@ -203,10 +201,16 @@
 
 /**屏幕旋转的通知回调*/
 - (void)orientChange:(NSNotification *)noti {
+    
+    if(_didHandlePortraitType){
+        return;
+    }
+    _didHandlePortraitType = YES;
+    
     UIDeviceOrientation  orient = [UIDevice currentDevice].orientation;
     switch (orient) {
         case UIDeviceOrientationPortrait:
-            NSLog(@"竖直屏幕");
+            HLog(@"竖直屏幕");
             if(!_isPortraitType){
                 [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:^{
                     [self screenLandscapeToPortraitFun];
@@ -214,24 +218,25 @@
             }
             break;
         case UIDeviceOrientationLandscapeLeft:
-            NSLog(@"手机左转");
+            HLog(@"手机左转");
             if(_isPortraitType){
                 [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:^{
                     [self screenPortraitToLandscapeFun];
                 }];
             }
+            _didHandlePortraitType = NO;
             break;
         case UIDeviceOrientationPortraitUpsideDown:
            // NSLog(@"手机竖直");
             break;
         case UIDeviceOrientationLandscapeRight:
-            NSLog(@"手机右转");
+            HLog(@"手机右转");
             if(_isPortraitType){
                 [self.player rotateToOrientation:UIInterfaceOrientationLandscapeLeft animated:NO completion:^{
                     [self screenPortraitToLandscapeFun];
                 }];
-                
             }
+            _didHandlePortraitType = NO;
             break;
         case UIDeviceOrientationUnknown:
             //NSLog(@"未知");
@@ -364,10 +369,12 @@
     //横屏
     //_controlView.landScapeControlView.fullScreenBtn.hidden = YES;
     
+    //[_controlView.landScapeControlView.backBtn addTarget:self action:@selector(didClickBackBtnFun) forControlEvents:UIControlEventTouchUpInside];
+    
     UILabel *titleLabInlandScape = _controlView.landScapeControlView.titleLabel;
     titleLabInlandScape.textAlignment = NSTextAlignmentCenter;
     titleLabInlandScape.lineBreakMode = NSLineBreakByTruncatingMiddle;
-    CGRect titleLabFrameInlandScape = titleLabInlandScape.frame;
+    //CGRect titleLabFrameInlandScape = titleLabInlandScape.frame;
     //titleLabInlandScape.backgroundColor = [UIColor greenColor];
     
     [titleLabInlandScape mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -453,6 +460,8 @@
 {
     [self.player stop];
     
+    //_didClickBackType = YES;
+    
     if(_isCodeSuspendAudioType){
         [[DFPlayer sharedPlayer] df_play];
     }

+ 10 - 11
创维盒子/双子星云手机/Vendor/ZFPlayer/Classes/Core/ZFLandscapeRotationManager_iOS15.m

@@ -50,17 +50,16 @@
     _rotateCompleted = completion;
     self.forceRotaion = YES;
     
-    //hxd del 20240718  里面实现的横竖屏转换不灵敏 外面做了处理
-//    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
-//        SEL selector = NSSelectorFromString(@"setOrientation:");
-//        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
-//        [invocation setSelector:selector];
-//        [invocation setTarget:[UIDevice currentDevice]];
-//        UIInterfaceOrientation val = orientation;
-//        [invocation setArgument:&val atIndex:2];
-//        [invocation invoke];
-//    }
-//    [UIViewController attemptRotationToDeviceOrientation];
+    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
+        SEL selector = NSSelectorFromString(@"setOrientation:");
+        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
+        [invocation setSelector:selector];
+        [invocation setTarget:[UIDevice currentDevice]];
+        UIInterfaceOrientation val = orientation;
+        [invocation setArgument:&val atIndex:2];
+        [invocation invoke];
+    }
+    [UIViewController attemptRotationToDeviceOrientation];
 }
 
 - (UIView *)fullScreenContainerView {