Przeglądaj źródła

VLCMovieViewController: 360 videos fix rotationlock

on iPad with iOS 9 and higher shouldAutorotate is never called since all orientations are supported by default when
we support multitasking. This lead to no rotationlock when interfacelock was enabled or a 360 video was played.
We're now using supportedInterfaceOrientations: and lock 360 videos to portrait and for interfacelock we save the current orientation and return it.
Carola Nitz 7 lat temu
rodzic
commit
6c02f6256a

+ 0 - 2
Sources/VLCMovieViewController.h

@@ -103,6 +103,4 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
 - (void)toggleChapterAndTitleSelector;
 - (void)hideMenu;
 
-- (BOOL)rotationIsDisabled;
-
 @end

+ 9 - 2
Sources/VLCMovieViewController.m

@@ -114,6 +114,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     CGFloat _fov;
     CGPoint _saveLocation;
     CGSize _screenPixelSize;
+    UIInterfaceOrientation _lockedOrientation;
 }
 @property (nonatomic, strong) VLCMovieViewControlPanelView *controllerPanel;
 @property (nonatomic, strong) UIPopoverController *masterPopoverController;
@@ -396,6 +397,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     [super viewWillAppear:animated];
 
     _vpc.delegate = self;
+    _lockedOrientation = UIInterfaceOrientationPortrait;
     [_vpc recoverPlaybackState];
     self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
@@ -1194,6 +1196,9 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 - (void)toggleUILock
 {
     _interfaceIsLocked = !_interfaceIsLocked;
+    if (_interfaceIsLocked) {
+        _lockedOrientation = [[UIApplication sharedApplication] statusBarOrientation];
+    }
 
     NSArray *items = [self itemsForInterfaceLock];
 
@@ -1605,9 +1610,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 
 #pragma mark - autorotation
 
-- (BOOL)rotationIsDisabled
+- (UIInterfaceOrientationMask)supportedInterfaceOrientations
 {
-    return _interfaceIsLocked || [_vpc currentMediaIs360Video];
+    BOOL orientationIslocked = _interfaceIsLocked || [_vpc currentMediaIs360Video];
+    UIInterfaceOrientationMask maskFromOrientation = 1 << _lockedOrientation;
+    return orientationIslocked ? maskFromOrientation :  UIInterfaceOrientationMaskAll;
 }
 
 - (BOOL)shouldAutorotate

+ 0 - 14
Sources/VLCPlaybackNavigationController.m

@@ -11,9 +11,6 @@
  *****************************************************************************/
 
 #import "VLCPlaybackNavigationController.h"
-#if TARGET_OS_IOS
-#import "VLCMovieViewController.h"
-#endif
 
 @implementation VLCPlaybackNavigationController
 
@@ -22,15 +19,4 @@
     return [self.topViewController supportedInterfaceOrientations];
 }
 
-#if TARGET_OS_IOS
-- (BOOL)shouldAutorotate
-{
-    id topVC = self.topViewController;
-    if ([topVC isKindOfClass:[VLCMovieViewController class]])
-        return ![(VLCMovieViewController *)topVC rotationIsDisabled];
-
-    return YES;
-}
-#endif
-
 @end