Commit 6667c4a9 authored by Carola Nitz's avatar Carola Nitz

VLCMovieViewController: toggle between filltoCrop and previous aspect ratio...

VLCMovieViewController: toggle between filltoCrop and previous aspect ratio for double tap on iPhoneX and refactored the aspect ratio code

(cherry picked from commit 9469da72)
parent 071183c3
......@@ -141,6 +141,10 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
[super viewDidLoad];
CGRect rect;
_vpc = [VLCPlaybackController sharedInstance];
_vpc.delegate = self;
[_vpc recoverPlaybackState];
self.extendedLayoutIncludesOpaqueBars = YES;
self.edgesForExtendedLayout = UIRectEdgeAll;
......@@ -256,7 +260,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_pinchRecognizer.delegate = self;
if ([[UIDevice currentDevice] isiPhoneX]) {
_tapToToggleiPhoneXRatioRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleiPhoneXAspectRatio)];
_tapToToggleiPhoneXRatioRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:_vpc action:@selector(switchIPhoneXFullScreen)];
_tapToToggleiPhoneXRatioRecognizer.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:_tapToToggleiPhoneXRatioRecognizer];
} else {
......@@ -400,10 +404,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
self.artistNameLabel.text = nil;
self.albumNameLabel.text = nil;
_vpc = [VLCPlaybackController sharedInstance];
_vpc.delegate = self;
[_vpc recoverPlaybackState];
[self screenBrightnessChanged:nil];
[self setControlsHidden:NO animated:animated];
......@@ -1581,7 +1581,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[self _resetIdleTimer];
}
#pragma mark - autorotation
- (BOOL)rotationIsDisabled
......
......@@ -114,6 +114,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)setAudioPassthrough:(BOOL)shouldPass;
- (void)switchAspectRatio;
- (void)switchIPhoneXFullScreen;
#if !TARGET_OS_TV
- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute;
- (NSInteger)currentMediaProjection;
......
......@@ -251,7 +251,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
_currentAspectRatio = VLCAspectRatioDefault;
_mediaPlayer.videoAspectRatio = NULL;
_mediaPlayer.scaleFactor = 0;
_mediaPlayer.videoCropGeometry = NULL;
[[self remoteControlService] subscribeToRemoteCommands];
......@@ -834,6 +834,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
}
}
- (void)jumpForward:(int)interval
{
[_mediaPlayer jumpForward:interval];
......@@ -844,28 +845,38 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
[_mediaPlayer jumpBackward:interval];
}
- (void)switchAspectRatio
- (NSString *)screenAspectRatio
{
if (_currentAspectRatio == VLCAspectRatioSixteenToTen) {
_mediaPlayer.videoAspectRatio = NULL;
_mediaPlayer.scaleFactor = 0;
_currentAspectRatio = VLCAspectRatioDefault;
} else {
_currentAspectRatio++;
UIScreen *screen = [[UIDevice currentDevice] VLCHasExternalDisplay] ? [UIScreen screens][1] : [UIScreen mainScreen];
return [NSString stringWithFormat:@"%d:%d", (int)screen.bounds.size.width, (int)screen.bounds.size.height];
}
if (_currentAspectRatio == VLCAspectRatioFillToScreen) {
UIScreen *screen;
if (![[UIDevice currentDevice] VLCHasExternalDisplay])
screen = [UIScreen mainScreen];
else
screen = [UIScreen screens][1];
- (void)switchIPhoneXFullScreen
{
BOOL inFullScreen = _mediaPlayer.videoCropGeometry && [[NSString stringWithUTF8String:_mediaPlayer.videoCropGeometry] isEqualToString:[self screenAspectRatio]];
if (inFullScreen) {
const char *previousAspectRatio = _currentAspectRatio == VLCAspectRatioDefault ? NULL : [[self stringForAspectRatio:_currentAspectRatio] UTF8String];
_mediaPlayer.videoAspectRatio = (char *)previousAspectRatio;
}
_mediaPlayer.videoCropGeometry = inFullScreen ? NULL : (char *)[[self screenAspectRatio] UTF8String];
}
NSString *aspectRatio = [NSString stringWithFormat:@"%d:%d", (int)screen.bounds.size.width, (int)screen.bounds.size.height];
_mediaPlayer.videoCropGeometry = (char *)[aspectRatio UTF8String];
} else {
_mediaPlayer.videoAspectRatio = (char *)[[self stringForAspectRatio:_currentAspectRatio] UTF8String];
- (void)switchAspectRatio
{
_currentAspectRatio = _currentAspectRatio == VLCAspectRatioSixteenToTen ? VLCAspectRatioDefault : _currentAspectRatio + 1;
switch (_currentAspectRatio) {
case VLCAspectRatioDefault:
_mediaPlayer.videoAspectRatio = NULL;
_mediaPlayer.videoCropGeometry = NULL;
}
break;
case VLCAspectRatioFillToScreen:
_mediaPlayer.videoCropGeometry = (char *)[[self screenAspectRatio] UTF8String];
break;
case VLCAspectRatioFourToThree:
case VLCAspectRatioSixteenToTen:
case VLCAspectRatioSixteenToNine:
_mediaPlayer.videoCropGeometry = NULL;
_mediaPlayer.videoAspectRatio = (char *)[[self stringForAspectRatio:_currentAspectRatio] UTF8String];
}
if ([self.delegate respondsToSelector:@selector(showStatusMessage:forPlaybackController:)]) {
......
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