Commit da60f129 authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackController: use scalefactor and added enum for different...

VLCPlaybackController: use scalefactor and added enum for different aspectratios to fix changing between different aspectratios

(cherry picked from commit 134fbd7e)
parent dd8ff3a8
Pipeline #157 failed with stage
in 0 seconds
...@@ -413,7 +413,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -413,7 +413,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_playbackWillClose = NO; _playbackWillClose = NO;
[_vpc recoverDisplayedMetadata]; [_vpc recoverDisplayedMetadata];
_vpc.videoOutputView = nil;
_vpc.videoOutputView = self.movieView; _vpc.videoOutputView = self.movieView;
_multiSelectionView.repeatMode = _vpc.repeatMode; _multiSelectionView.repeatMode = _vpc.repeatMode;
_multiSelectionView.shuffleMode = _vpc.isShuffleMode; _multiSelectionView.shuffleMode = _vpc.isShuffleMode;
...@@ -1540,7 +1539,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1540,7 +1539,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen) { if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen) {
[_vpc recoverDisplayedMetadata]; [_vpc recoverDisplayedMetadata];
if (_vpc.videoOutputView != self.movieView) { if (_vpc.videoOutputView != self.movieView) {
_vpc.videoOutputView = nil;
_vpc.videoOutputView = self.movieView; _vpc.videoOutputView = self.movieView;
} }
} }
......
...@@ -39,6 +39,14 @@ NSString *const VLCPlaybackControllerPlaybackMetadataDidChange = @"VLCPlaybackCo ...@@ -39,6 +39,14 @@ NSString *const VLCPlaybackControllerPlaybackMetadataDidChange = @"VLCPlaybackCo
NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPlaybackDidFail"; NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPlaybackDidFail";
NSString *const VLCPlaybackControllerPlaybackPositionUpdated = @"VLCPlaybackControllerPlaybackPositionUpdated"; NSString *const VLCPlaybackControllerPlaybackPositionUpdated = @"VLCPlaybackControllerPlaybackPositionUpdated";
typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
VLCAspectRatioDefault = 0,
VLCAspectRatioFillToScreen,
VLCAspectRatioFourToThree,
VLCAspectRatioSixteenToNine,
VLCAspectRatioSixteenToTen,
};
@interface VLCPlaybackController () <VLCMediaPlayerDelegate, @interface VLCPlaybackController () <VLCMediaPlayerDelegate,
#if TARGET_OS_IOS #if TARGET_OS_IOS
AVAudioSessionDelegate, AVAudioSessionDelegate,
...@@ -51,8 +59,7 @@ VLCMediaDelegate> ...@@ -51,8 +59,7 @@ VLCMediaDelegate>
BOOL _shouldResumePlayingAfterInteruption; BOOL _shouldResumePlayingAfterInteruption;
NSTimer *_sleepTimer; NSTimer *_sleepTimer;
NSArray *_aspectRatios; NSUInteger _currentAspectRatio;
NSUInteger _currentAspectRatioMask;
float _currentPlaybackRate; float _currentPlaybackRate;
UIView *_videoOutputViewWrapper; UIView *_videoOutputViewWrapper;
...@@ -229,8 +236,6 @@ VLCMediaDelegate> ...@@ -229,8 +236,6 @@ VLCMediaDelegate>
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_aspectRatios = @[@"DEFAULT", @"FILL_TO_SCREEN", @"4:3", @"16:9", @"16:10", @"2.21:1"];
if (!self.url && !self.mediaList) { if (!self.url && !self.mediaList) {
APLog(@"%s: no URL and no media list set, stopping playback", __PRETTY_FUNCTION__); APLog(@"%s: no URL and no media list set, stopping playback", __PRETTY_FUNCTION__);
[_playbackSessionManagementLock unlock]; [_playbackSessionManagementLock unlock];
...@@ -345,8 +350,9 @@ VLCMediaDelegate> ...@@ -345,8 +350,9 @@ VLCMediaDelegate>
if ([self.delegate respondsToSelector:@selector(prepareForMediaPlayback:)]) if ([self.delegate respondsToSelector:@selector(prepareForMediaPlayback:)])
[self.delegate prepareForMediaPlayback:self]; [self.delegate prepareForMediaPlayback:self];
_currentAspectRatioMask = 0; _currentAspectRatio = VLCAspectRatioDefault;
_mediaPlayer.videoAspectRatio = NULL; _mediaPlayer.videoAspectRatio = NULL;
_mediaPlayer.scaleFactor = 0;
[self subscribeRemoteCommands]; [self subscribeRemoteCommands];
...@@ -729,18 +735,14 @@ VLCMediaDelegate> ...@@ -729,18 +735,14 @@ VLCMediaDelegate>
- (void)switchAspectRatio - (void)switchAspectRatio
{ {
NSUInteger count = [_aspectRatios count]; if (_currentAspectRatio == VLCAspectRatioSixteenToTen) {
if (_currentAspectRatioMask + 1 > count - 1) {
_mediaPlayer.videoAspectRatio = NULL; _mediaPlayer.videoAspectRatio = NULL;
_mediaPlayer.videoCropGeometry = NULL; _mediaPlayer.scaleFactor = 0;
_currentAspectRatioMask = 0; _currentAspectRatio = VLCAspectRatioDefault;
if ([self.delegate respondsToSelector:@selector(showStatusMessage:forPlaybackController:)])
[self.delegate showStatusMessage:[NSString stringWithFormat:NSLocalizedString(@"AR_CHANGED", nil), NSLocalizedString(@"DEFAULT", nil)] forPlaybackController:self];
} else { } else {
_currentAspectRatioMask++; _currentAspectRatio++;
if ([_aspectRatios[_currentAspectRatioMask] isEqualToString:@"FILL_TO_SCREEN"]) { if (_currentAspectRatio == VLCAspectRatioFillToScreen) {
UIScreen *screen; UIScreen *screen;
if (![[UIDevice currentDevice] VLCHasExternalDisplay]) if (![[UIDevice currentDevice] VLCHasExternalDisplay])
screen = [UIScreen mainScreen]; screen = [UIScreen mainScreen];
...@@ -749,27 +751,41 @@ VLCMediaDelegate> ...@@ -749,27 +751,41 @@ VLCMediaDelegate>
float f_ar = screen.bounds.size.width / screen.bounds.size.height; float f_ar = screen.bounds.size.width / screen.bounds.size.height;
if (f_ar == (float)(640./1136.)) // iPhone 5 aka 16:9.01 if (f_ar == (float)(640./1136.)) {// iPhone 5 aka 16:9.01
_mediaPlayer.videoCropGeometry = "16:9"; _mediaPlayer.videoAspectRatio = "16:9";
else if (f_ar == (float)(2./3.)) // all other iPhones } else if (f_ar == (float)(2./3.)) {// all other iPhones
_mediaPlayer.videoCropGeometry = "16:10"; // libvlc doesn't support 2:3 crop _mediaPlayer.videoAspectRatio = "16:10"; // libvlc doesn't support 2:3 crop
else if (f_ar == (float)(1. + (1./3.))) // all iPads } else if (f_ar == (float)(1. + (1./3.))) {// all iPads
_mediaPlayer.videoCropGeometry = "4:3"; _mediaPlayer.videoAspectRatio = "4:3";
else if (f_ar == .5625) // AirPlay } else if (f_ar == .5625) {// AirPlay
_mediaPlayer.videoCropGeometry = "16:9"; _mediaPlayer.videoAspectRatio = "16:9";
else } else
APLog(@"unknown screen format %f, can't crop", f_ar); APLog(@"unknown screen format %f, can't crop", f_ar);
} else {
if ([self.delegate respondsToSelector:@selector(showStatusMessage:forPlaybackController:)]) _mediaPlayer.videoAspectRatio = (char *)[[self stringForAspectRatio:_currentAspectRatio] UTF8String];
[self.delegate showStatusMessage:NSLocalizedString(@"FILL_TO_SCREEN", nil) forPlaybackController:self]; _mediaPlayer.scaleFactor = 0;
return;
} }
}
if ([self.delegate respondsToSelector:@selector(showStatusMessage:forPlaybackController:)]) {
[self.delegate showStatusMessage:[NSString stringWithFormat:NSLocalizedString(@"AR_CHANGED", nil), [self stringForAspectRatio:_currentAspectRatio]] forPlaybackController:self];
}
}
_mediaPlayer.videoCropGeometry = NULL; - (NSString *)stringForAspectRatio:(VLCAspectRatio)ratio
_mediaPlayer.videoAspectRatio = (char *)[_aspectRatios[_currentAspectRatioMask] UTF8String]; {
switch (ratio) {
if ([self.delegate respondsToSelector:@selector(showStatusMessage:forPlaybackController:)]) case VLCAspectRatioFillToScreen:
[self.delegate showStatusMessage:[NSString stringWithFormat:NSLocalizedString(@"AR_CHANGED", nil), _aspectRatios[_currentAspectRatioMask]] forPlaybackController:self]; return NSLocalizedString(@"FILL_TO_SCREEN", nil);
case VLCAspectRatioDefault:
return NSLocalizedString(@"DEFAULT", nil);
case VLCAspectRatioFourToThree:
return NSLocalizedString(@"4:3", nil);
case VLCAspectRatioSixteenToTen:
return NSLocalizedString(@"16:10", nil);
case VLCAspectRatioSixteenToNine:
return NSLocalizedString(@"16:9", nil);
default:
NSAssert(NO, @"this shouldn't happen");
} }
} }
......
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