Commit b85f4d42 authored by Carola Nitz's avatar Carola Nitz

VLCMovieViewcontroller: bring tap to Fullscreen to all devices

(cherry picked from commit a918175a)
parent 980399c2
......@@ -16,5 +16,5 @@
@property (readonly) NSNumber *VLCFreeDiskSpace;
@property (readonly) BOOL VLCHasExternalDisplay;
@property (readonly) BOOL isiPhoneX;
@end
......@@ -42,23 +42,4 @@
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
......@@ -92,8 +92,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
UISwipeGestureRecognizer *_swipeRecognizerDown;
UITapGestureRecognizer *_tapRecognizer;
UITapGestureRecognizer *_tapOnVideoRecognizer;
UITapGestureRecognizer *_tapToToggleiPhoneXRatioRecognizer;
UITapGestureRecognizer *_tapToSeekRecognizer;
UITapGestureRecognizer *_doubleTapRecognizer;
UIButton *_doneButton;
......@@ -252,16 +251,11 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
_pinchRecognizer.delegate = self;
if ([[UIDevice currentDevice] isiPhoneX]) {
_tapToToggleiPhoneXRatioRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:_vpc action:@selector(switchIPhoneXFullScreen)];
_tapToToggleiPhoneXRatioRecognizer.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:_tapToToggleiPhoneXRatioRecognizer];
} else {
_tapToSeekRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToSeekRecognized:)];
[_tapToSeekRecognizer setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:_tapToSeekRecognizer];
[_tapOnVideoRecognizer requireGestureRecognizerToFail:_tapToSeekRecognizer];
}
_doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapRecognized:)];
[_doubleTapRecognizer setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:_doubleTapRecognizer];
[_tapOnVideoRecognizer requireGestureRecognizerToFail:_doubleTapRecognizer];
_tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(togglePlayPause)];
[_tapRecognizer setNumberOfTouchesRequired:2];
......@@ -300,7 +294,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_swipeRecognizerUp.delegate = self;
_swipeRecognizerDown.delegate = self;
_tapRecognizer.delegate = self;
_tapToSeekRecognizer.delegate = self;
_doubleTapRecognizer.delegate = self;
}
- (void)setupControlPanel
......@@ -635,30 +629,26 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (NSArray *)itemsForInterfaceLock
{
NSMutableArray *items = [[NSMutableArray alloc] initWithArray: @[_pinchRecognizer,
_panRecognizer,
_tapRecognizer,
_doneButton,
_timeNavigationTitleView.minimizePlaybackButton,
_timeNavigationTitleView.positionSlider,
_timeNavigationTitleView.aspectRatioButton,
_controllerPanel.playbackSpeedButton,
_controllerPanel.trackSwitcherButton,
_controllerPanel.bwdButton,
_controllerPanel.playPauseButton,
_controllerPanel.fwdButton,
_controllerPanel.videoFilterButton,
_multiSelectionView.equalizerButton,
_multiSelectionView.chapterSelectorButton,
_multiSelectionView.repeatButton,
_multiSelectionView.shuffleButton,
_controllerPanel.volumeView,
_rendererButton]];
[[UIDevice currentDevice] isiPhoneX] ? [items addObject:_tapToToggleiPhoneXRatioRecognizer]
: [items addObject:_tapToSeekRecognizer];
return [items copy];
return @[_pinchRecognizer,
_panRecognizer,
_tapRecognizer,
_doneButton,
_doubleTapRecognizer,
_timeNavigationTitleView.minimizePlaybackButton,
_timeNavigationTitleView.positionSlider,
_timeNavigationTitleView.aspectRatioButton,
_controllerPanel.playbackSpeedButton,
_controllerPanel.trackSwitcherButton,
_controllerPanel.bwdButton,
_controllerPanel.playPauseButton,
_controllerPanel.fwdButton,
_controllerPanel.videoFilterButton,
_multiSelectionView.equalizerButton,
_multiSelectionView.chapterSelectorButton,
_multiSelectionView.repeatButton,
_multiSelectionView.shuffleButton,
_controllerPanel.volumeView,
_rendererButton];
}
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer
......@@ -1522,24 +1512,25 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
}
}
- (void)tapToSeekRecognized:(UITapGestureRecognizer *)tapRecognizer
- (void)doubleTapRecognized:(UITapGestureRecognizer *)tapRecognizer
{
if (!_seekGestureEnabled)
return;
CGFloat screenHalf;
CGFloat tmpPosition;
CGSize size = self.view.frame.size;
CGPoint tapPosition = [tapRecognizer locationInView:self.view];
CGFloat screenWidth = self.view.frame.size.width;
CGFloat backwardBoundary = screenWidth / 3.0;
CGFloat forwardBoundary = 2 * screenWidth / 3.0;
screenHalf = size.width / 2;
tmpPosition = tapPosition.x;
CGPoint tapPosition = [tapRecognizer locationInView:self.view];
//Handling seek reset if tap orientation changes.
if (tmpPosition < screenHalf) {
if (tapPosition.x < backwardBoundary) {
_numberOfTapSeek = _previousJumpState == VLCMovieJumpStateForward ? -1 : _numberOfTapSeek - 1;
} else {
} else if (tapPosition.x > forwardBoundary){
_numberOfTapSeek = _previousJumpState == VLCMovieJumpStateBackward ? 1 : _numberOfTapSeek + 1;
} else {
[_vpc toggleFullScreen];
return;
}
_isTapSeeking = YES;
......
......@@ -122,7 +122,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setAudioPassthrough:(BOOL)shouldPass;
- (void)switchAspectRatio;
- (void)switchIPhoneXFullScreen;
- (void)toggleFullScreen;
#if !TARGET_OS_TV
- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute;
- (NSInteger)currentMediaProjection;
......
......@@ -877,7 +877,7 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
_isInFillToScreen = YES;
}
- (void)switchIPhoneXFullScreen
- (void)toggleFullScreen
{
if (_isInFillToScreen) {
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