Commit a918175a authored by Carola Nitz's avatar Carola Nitz

VLCMovieViewcontroller: bring tap to Fullscreen to all devices

parent 902f2c4b
...@@ -16,5 +16,5 @@ ...@@ -16,5 +16,5 @@
@property (readonly) NSNumber *VLCFreeDiskSpace; @property (readonly) NSNumber *VLCFreeDiskSpace;
@property (readonly) BOOL VLCHasExternalDisplay; @property (readonly) BOOL VLCHasExternalDisplay;
@property (readonly) BOOL isiPhoneX;
@end @end
...@@ -42,23 +42,4 @@ ...@@ -42,23 +42,4 @@
return ([[UIScreen screens] count] > 1); return ([[UIScreen screens] count] > 1);
} }
- (BOOL)isiPhoneX
{
static BOOL isiPhoneX = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if TARGET_IPHONE_SIMULATOR
NSString *model = NSProcessInfo.processInfo.environment[@"SIMULATOR_MODEL_IDENTIFIER"];
#else
struct utsname systemInfo;
uname(&systemInfo);
NSString *model = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
#endif
isiPhoneX = [model isEqualToString:@"iPhone10,3"] || [model isEqualToString:@"iPhone10,6"];
});
return isiPhoneX;
}
@end @end
...@@ -88,8 +88,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -88,8 +88,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
UISwipeGestureRecognizer *_swipeRecognizerDown; UISwipeGestureRecognizer *_swipeRecognizerDown;
UITapGestureRecognizer *_tapRecognizer; UITapGestureRecognizer *_tapRecognizer;
UITapGestureRecognizer *_tapOnVideoRecognizer; UITapGestureRecognizer *_tapOnVideoRecognizer;
UITapGestureRecognizer *_tapToToggleiPhoneXRatioRecognizer; UITapGestureRecognizer *_doubleTapRecognizer;
UITapGestureRecognizer *_tapToSeekRecognizer;
UIButton *_doneButton; UIButton *_doneButton;
...@@ -254,16 +253,11 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -254,16 +253,11 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)]; _pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
_pinchRecognizer.delegate = self; _pinchRecognizer.delegate = self;
if ([[UIDevice currentDevice] isiPhoneX]) { _doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapRecognized:)];
_tapToToggleiPhoneXRatioRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:_vpc action:@selector(switchIPhoneXFullScreen)]; [_doubleTapRecognizer setNumberOfTapsRequired:2];
_tapToToggleiPhoneXRatioRecognizer.numberOfTapsRequired = 2; [self.view addGestureRecognizer:_doubleTapRecognizer];
[self.view addGestureRecognizer:_tapToToggleiPhoneXRatioRecognizer]; [_tapOnVideoRecognizer requireGestureRecognizerToFail:_doubleTapRecognizer];
} else {
_tapToSeekRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToSeekRecognized:)];
[_tapToSeekRecognizer setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:_tapToSeekRecognizer];
[_tapOnVideoRecognizer requireGestureRecognizerToFail:_tapToSeekRecognizer];
}
_tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(togglePlayPause)]; _tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(togglePlayPause)];
[_tapRecognizer setNumberOfTouchesRequired:2]; [_tapRecognizer setNumberOfTouchesRequired:2];
...@@ -302,7 +296,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -302,7 +296,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_swipeRecognizerUp.delegate = self; _swipeRecognizerUp.delegate = self;
_swipeRecognizerDown.delegate = self; _swipeRecognizerDown.delegate = self;
_tapRecognizer.delegate = self; _tapRecognizer.delegate = self;
_tapToSeekRecognizer.delegate = self; _doubleTapRecognizer.delegate = self;
} }
- (void)setupControlPanel - (void)setupControlPanel
...@@ -655,10 +649,11 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -655,10 +649,11 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (NSArray *)itemsForInterfaceLock - (NSArray *)itemsForInterfaceLock
{ {
NSMutableArray *items = [[NSMutableArray alloc] initWithArray: @[_pinchRecognizer, return @[_pinchRecognizer,
_panRecognizer, _panRecognizer,
_tapRecognizer, _tapRecognizer,
_doneButton, _doneButton,
_doubleTapRecognizer,
_timeNavigationTitleView.minimizePlaybackButton, _timeNavigationTitleView.minimizePlaybackButton,
_timeNavigationTitleView.positionSlider, _timeNavigationTitleView.positionSlider,
_timeNavigationTitleView.aspectRatioButton, _timeNavigationTitleView.aspectRatioButton,
...@@ -673,12 +668,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -673,12 +668,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_multiSelectionView.repeatButton, _multiSelectionView.repeatButton,
_multiSelectionView.shuffleButton, _multiSelectionView.shuffleButton,
_controllerPanel.volumeView, _controllerPanel.volumeView,
_rendererButton]]; _rendererButton];
[[UIDevice currentDevice] isiPhoneX] ? [items addObject:_tapToToggleiPhoneXRatioRecognizer]
: [items addObject:_tapToSeekRecognizer];
return [items copy];
} }
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer - (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer
...@@ -1559,24 +1549,25 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1559,24 +1549,25 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
} }
} }
- (void)tapToSeekRecognized:(UITapGestureRecognizer *)tapRecognizer - (void)doubleTapRecognized:(UITapGestureRecognizer *)tapRecognizer
{ {
if (!_seekGestureEnabled) if (!_seekGestureEnabled)
return; return;
CGFloat screenHalf; CGFloat screenWidth = self.view.frame.size.width;
CGFloat tmpPosition; CGFloat backwardBoundary = screenWidth / 3.0;
CGSize size = self.view.frame.size; CGFloat forwardBoundary = 2 * screenWidth / 3.0;
CGPoint tapPosition = [tapRecognizer locationInView:self.view];
screenHalf = size.width / 2; CGPoint tapPosition = [tapRecognizer locationInView:self.view];
tmpPosition = tapPosition.x;
//Handling seek reset if tap orientation changes. //Handling seek reset if tap orientation changes.
if (tmpPosition < screenHalf) { if (tapPosition.x < backwardBoundary) {
_numberOfTapSeek = _previousJumpState == VLCMovieJumpStateForward ? -1 : _numberOfTapSeek - 1; _numberOfTapSeek = _previousJumpState == VLCMovieJumpStateForward ? -1 : _numberOfTapSeek - 1;
} else { } else if (tapPosition.x > forwardBoundary){
_numberOfTapSeek = _previousJumpState == VLCMovieJumpStateBackward ? 1 : _numberOfTapSeek + 1; _numberOfTapSeek = _previousJumpState == VLCMovieJumpStateBackward ? 1 : _numberOfTapSeek + 1;
} else {
[_vpc toggleFullScreen];
return;
} }
_isTapSeeking = YES; _isTapSeeking = YES;
......
...@@ -122,7 +122,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -122,7 +122,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setAudioPassthrough:(BOOL)shouldPass; - (void)setAudioPassthrough:(BOOL)shouldPass;
- (void)switchAspectRatio; - (void)switchAspectRatio;
- (void)switchIPhoneXFullScreen; - (void)toggleFullScreen;
#if !TARGET_OS_TV #if !TARGET_OS_TV
- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute; - (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute;
- (NSInteger)currentMediaProjection; - (NSInteger)currentMediaProjection;
......
...@@ -882,7 +882,7 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) { ...@@ -882,7 +882,7 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
_isInFillToScreen = YES; _isInFillToScreen = YES;
} }
- (void)switchIPhoneXFullScreen - (void)toggleFullScreen
{ {
if (_isInFillToScreen) { if (_isInFillToScreen) {
const char *previousAspectRatio = _currentAspectRatio == VLCAspectRatioDefault ? NULL : [[self stringForAspectRatio:_currentAspectRatio] UTF8String]; const char *previousAspectRatio = _currentAspectRatio == VLCAspectRatioDefault ? NULL : [[self stringForAspectRatio:_currentAspectRatio] UTF8String];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment