Commit f0192bec authored by Carola Nitz's avatar Carola Nitz

VLCDisplayController, VLCMiniPlaybackView: first playback fixes

Created a subclass for the  view of the VLCDisplayController to let touches go through
Have only one instance of the Playbackcontroller that is going to be part of the tabbarcontroller
Changed the code that is currently calculating the miniviews position. This still needs fixing in case you turn the phone
parent fe372899
...@@ -386,11 +386,10 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -386,11 +386,10 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
return; return;
} }
} }
__weak typeof(self) weakself = self;
[self validatePasscodeIfNeededWithCompletion:^{ [self validatePasscodeIfNeededWithCompletion:^{
//[weakself.libraryViewController updateViewContents]; //TODO: handle updating the videoview and
if ([VLCPlaybackController sharedInstance].isPlaying){ if ([VLCPlaybackController sharedInstance].isPlaying){
[[VLCPlayerDisplayController sharedInstance] pushPlaybackView]; //TODO: push playback
} }
}]; }];
[[MLMediaLibrary sharedMediaLibrary] applicationWillExit]; [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
...@@ -401,6 +400,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -401,6 +400,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if (!_isRunningMigration && !_isComingFromHandoff) { if (!_isRunningMigration && !_isComingFromHandoff) {
[[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase]; [[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
// [[VLCMediaFileDiscoverer sharedInstance] updateMediaList]; // [[VLCMediaFileDiscoverer sharedInstance] updateMediaList];
[[VLCPlaybackController sharedInstance] recoverDisplayedMetadata];
} else if(_isComingFromHandoff) { } else if(_isComingFromHandoff) {
_isComingFromHandoff = NO; _isComingFromHandoff = NO;
} }
...@@ -453,7 +453,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -453,7 +453,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
- (void)validatePasscodeIfNeededWithCompletion:(void(^)(void))completion - (void)validatePasscodeIfNeededWithCompletion:(void(^)(void))completion
{ {
if ([VLCKeychainCoordinator passcodeLockEnabled]) { if ([VLCKeychainCoordinator passcodeLockEnabled]) {
[[VLCPlayerDisplayController sharedInstance] dismissPlaybackView]; //TODO: Dimiss playback
[self.keychainCoordinator validatePasscodeWithCompletion:completion]; [self.keychainCoordinator validatePasscodeWithCompletion:completion];
} else { } else {
completion(); completion();
......
...@@ -456,7 +456,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -456,7 +456,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
_createFolderBarButtonItem.enabled = NO; _createFolderBarButtonItem.enabled = NO;
[_mediaDataSource addAllShows]; [_mediaDataSource addAllShows];
} break; } break;
//Todo: I'm not sure if updateViewContents should be called in VLCLibraryModeFolder //TODO: I'm not sure if updateViewContents should be called in VLCLibraryModeFolder
//Here should maybe be an NSAssert to prevent this but for now due to refactoring these calls would've been made in that case //Here should maybe be an NSAssert to prevent this but for now due to refactoring these calls would've been made in that case
case VLCLibraryModeAllFiles: case VLCLibraryModeAllFiles:
case VLCLibraryModeFolder: case VLCLibraryModeFolder:
......
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
* $Id$ * $Id$
* *
* Author: Felix Paul Kühne <fkuehne # videolan.org> * Author: Felix Paul Kühne <fkuehne # videolan.org>
* Carola Nitz <caro # videolan.org>
* *
* Refer to the COPYING file of the official project for license. * Refer to the COPYING file of the official project for license.
*****************************************************************************/ *****************************************************************************/
#import "VLCMiniPlaybackView.h" #import "VLCMiniPlaybackView.h"
#import "VLCPlaybackController.h"
#import "VLCPlayerDisplayController.h"
#import "VLCMetadata.h" #import "VLCMetadata.h"
#import "VLC_iOS-Swift.h" #import "VLC_iOS-Swift.h"
...@@ -38,12 +37,6 @@ ...@@ -38,12 +37,6 @@
self = [super initWithFrame:viewFrame]; self = [super initWithFrame:viewFrame];
if (self) { if (self) {
[self setupSubviews]; [self setupSubviews];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(appBecameActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
} }
return self; return self;
} }
...@@ -146,14 +139,6 @@ ...@@ -146,14 +139,6 @@
#endif #endif
} }
- (void)appBecameActive:(NSNotification *)aNotification
{
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeMiniplayer) {
[[VLCPlaybackController sharedInstance] recoverDisplayedMetadata];
}
}
- (void)tapRecognized - (void)tapRecognized
{ {
[self pushFullPlaybackView:nil]; [self pushFullPlaybackView:nil];
...@@ -209,6 +194,8 @@ ...@@ -209,6 +194,8 @@
[self updatePlayPauseButton]; [self updatePlayPauseButton];
controller.delegate = self; controller.delegate = self;
[controller recoverDisplayedMetadata]; [controller recoverDisplayedMetadata];
_videoView.hidden = false;
controller.videoOutputView = _videoView;
} }
- (void)mediaPlayerStateChanged:(VLCMediaPlayerState)currentState - (void)mediaPlayerStateChanged:(VLCMediaPlayerState)currentState
...@@ -228,11 +215,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -228,11 +215,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
_artworkView.image = metadata.artworkImage?: [UIImage imageNamed:@"no-artwork"]; _artworkView.image = metadata.artworkImage?: [UIImage imageNamed:@"no-artwork"];
} else { } else {
_artworkView.image = nil; _artworkView.image = nil;
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeMiniplayer) {
_videoView.hidden = false;
controller.videoOutputView = _videoView;
}
} }
NSString *metaDataString; NSString *metaDataString;
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
@class OBSlider; @class OBSlider;
@class VLCStatusLabel; @class VLCStatusLabel;
@class VLCHorizontalSwipeGestureRecognizer;
@class VLCVerticalSwipeGestureRecognizer; @class VLCVerticalSwipeGestureRecognizer;
@class VLCTimeNavigationTitleView; @class VLCTimeNavigationTitleView;
@class VLCMovieViewControlPanelView; @class VLCMovieViewControlPanelView;
@class VLCMovieViewController;
typedef NS_ENUM(NSInteger, VLCMovieJumpState) { typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
VLCMovieJumpStateDefault, VLCMovieJumpStateDefault,
...@@ -28,6 +28,11 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) { ...@@ -28,6 +28,11 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
VLCMovieJumpStateBackward VLCMovieJumpStateBackward
}; };
@protocol VLCMovieViewControllerDelegate
- (void)movieViewControllerDidSelectMinimize:(VLCMovieViewController *)movieViewController;
- (BOOL)movieViewControllerShouldBeDisplayed:(VLCMovieViewController *)movieViewController;
@end
@interface VLCMovieViewController : UIViewController <UIActionSheetDelegate, VLCPlaybackControllerDelegate> @interface VLCMovieViewController : UIViewController <UIActionSheetDelegate, VLCPlaybackControllerDelegate>
@property (nonatomic, strong) IBOutlet UIView *movieView; @property (nonatomic, strong) IBOutlet UIView *movieView;
...@@ -73,6 +78,8 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) { ...@@ -73,6 +78,8 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
@property (nonatomic, strong) IBOutlet UIImageView *artworkImageView; @property (nonatomic, strong) IBOutlet UIImageView *artworkImageView;
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *widthConstraint; @property (nonatomic, strong) IBOutlet NSLayoutConstraint *widthConstraint;
@property (nonatomic, weak) id<VLCMovieViewControllerDelegate> delegate;
- (IBAction)closePlayback:(id)sender; - (IBAction)closePlayback:(id)sender;
- (IBAction)minimizePlayback:(id)sender; - (IBAction)minimizePlayback:(id)sender;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCTimeNavigationTitleView.h" #import "VLCTimeNavigationTitleView.h"
#import "VLCPlayerDisplayController.h"
#import "VLCAppDelegate.h" #import "VLCAppDelegate.h"
#import "VLCStatusLabel.h" #import "VLCStatusLabel.h"
#import "VLCMovieViewControlPanelView.h" #import "VLCMovieViewControlPanelView.h"
...@@ -832,7 +831,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -832,7 +831,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (IBAction)minimizePlayback:(id)sender - (IBAction)minimizePlayback:(id)sender
{ {
LOCKCHECK; LOCKCHECK;
[[VLCPlayerDisplayController sharedInstance] closeFullscreenPlayback]; [_delegate movieViewControllerDidSelectMinimize:self];
} }
- (IBAction)positionSliderAction:(UISlider *)sender - (IBAction)positionSliderAction:(UISlider *)sender
...@@ -1512,8 +1511,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1512,8 +1511,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)appBecameActive:(NSNotification *)aNotification - (void)appBecameActive:(NSNotification *)aNotification
{ {
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance]; if ([_delegate movieViewControllerShouldBeDisplayed:self]) {
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen) {
[_vpc recoverDisplayedMetadata]; [_vpc recoverDisplayedMetadata];
if (_vpc.videoOutputView != self.movieView) { if (_vpc.videoOutputView != self.movieView) {
_vpc.videoOutputView = self.movieView; _vpc.videoOutputView = self.movieView;
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
*****************************************************************************/ *****************************************************************************/
#import "VLCEqualizerView.h" #import "VLCEqualizerView.h"
#if TARGET_OS_iOS
#import <MobileVLCKit/MobileVLCKit.h> #import <MobileVLCKit/MobileVLCKit.h>
#endif
extern NSString *const VLCPlaybackControllerPlaybackDidStart; extern NSString *const VLCPlaybackControllerPlaybackDidStart;
extern NSString *const VLCPlaybackControllerPlaybackDidPause; extern NSString *const VLCPlaybackControllerPlaybackDidPause;
extern NSString *const VLCPlaybackControllerPlaybackDidResume; extern NSString *const VLCPlaybackControllerPlaybackDidResume;
......
...@@ -30,8 +30,6 @@ typedef NS_ENUM(NSUInteger, VLCPlayerDisplayControllerDisplayMode) { ...@@ -30,8 +30,6 @@ typedef NS_ENUM(NSUInteger, VLCPlayerDisplayControllerDisplayMode) {
@interface VLCPlayerDisplayController : UIViewController @interface VLCPlayerDisplayController : UIViewController
+ (VLCPlayerDisplayController *)sharedInstance;
@property (nonatomic, assign) VLCPlayerDisplayControllerDisplayMode displayMode; @property (nonatomic, assign) VLCPlayerDisplayControllerDisplayMode displayMode;
@property (nonatomic, weak) VLCPlaybackController *playbackController; @property (nonatomic, weak) VLCPlaybackController *playbackController;
......
...@@ -24,30 +24,26 @@ ...@@ -24,30 +24,26 @@
static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDisplayControllerDisplayMode"; static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDisplayControllerDisplayMode";
@interface VLCPlayerDisplayController () @interface VLCUntouchableView: UIView
@property (nonatomic, strong) UIViewController<VLCPlaybackControllerDelegate> *movieViewController;
@property (nonatomic, strong) UIView<VLCPlaybackControllerDelegate, VLCMiniPlaybackViewInterface> *miniPlaybackView;
@property (nonatomic, strong) UIViewController *childViewController;
@end @end
@implementation VLCPlayerDisplayController @implementation VLCUntouchableView
+ (VLCPlayerDisplayController *)sharedInstance - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{ {
static VLCPlayerDisplayController *sharedInstance = nil; UIView *result = [super hitTest:point withEvent:event];
static dispatch_once_t pred; return result == self ? nil : result;
}
dispatch_once(&pred, ^{ @end
sharedInstance = [VLCPlayerDisplayController new];
});
return sharedInstance; @interface VLCPlayerDisplayController () <VLCMovieViewControllerDelegate>
} @property (nonatomic, strong) UIViewController<VLCPlaybackControllerDelegate> *movieViewController;
@property (nonatomic, strong) UIView<VLCPlaybackControllerDelegate, VLCMiniPlaybackViewInterface> *miniPlaybackView;
@property (nonatomic, strong) NSLayoutConstraint *bottomConstraint;
@end
+ (void)initialize @implementation VLCPlayerDisplayController
{
[[NSUserDefaults standardUserDefaults] registerDefaults:@{VLCPlayerDisplayControllerDisplayModeKey : @(VLCPlayerDisplayControllerDisplayModeFullscreen)}];
}
- (instancetype)init - (instancetype)init
{ {
...@@ -57,39 +53,14 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -57,39 +53,14 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
[notificationCenter addObserver:self selector:@selector(playbackDidStart:) name:VLCPlaybackControllerPlaybackDidStart object:nil]; [notificationCenter addObserver:self selector:@selector(playbackDidStart:) name:VLCPlaybackControllerPlaybackDidStart object:nil];
[notificationCenter addObserver:self selector:@selector(playbackDidFail:) name:VLCPlaybackControllerPlaybackDidFail object:nil]; [notificationCenter addObserver:self selector:@selector(playbackDidFail:) name:VLCPlaybackControllerPlaybackDidFail object:nil];
[notificationCenter addObserver:self selector:@selector(playbackDidStop:) name:VLCPlaybackControllerPlaybackDidStop object:nil]; [notificationCenter addObserver:self selector:@selector(playbackDidStop:) name:VLCPlaybackControllerPlaybackDidStop object:nil];
self.view.userInteractionEnabled = NO; [[NSUserDefaults standardUserDefaults] registerDefaults:@{VLCPlayerDisplayControllerDisplayModeKey : @(VLCPlayerDisplayControllerDisplayModeFullscreen)}];
} }
return self; return self;
} }
- (void)dealloc - (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - ChildViewController
- (void)setChildViewController:(UIViewController *)childViewController
{
if (_childViewController) {
[_childViewController willMoveToParentViewController:nil];
[_childViewController.view removeFromSuperview];
[_childViewController removeFromParentViewController];
}
_childViewController = childViewController;
if (self.isViewLoaded) {
[self setupChildViewController];
}
}
- (void)setupChildViewController
{ {
UIViewController *childViewController = self.childViewController; self.view = [[VLCUntouchableView alloc] initWithFrame:self.view.frame];
if (childViewController == nil)
return;
[self addChildViewController:childViewController];
[self.view addSubview:childViewController.view];
[childViewController didMoveToParentViewController:self];
} }
#pragma mark - properties #pragma mark - properties
...@@ -104,16 +75,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -104,16 +75,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
[[NSUserDefaults standardUserDefaults] setInteger:displayMode forKey:VLCPlayerDisplayControllerDisplayModeKey]; [[NSUserDefaults standardUserDefaults] setInteger:displayMode forKey:VLCPlayerDisplayControllerDisplayModeKey];
} }
- (void)viewSafeAreaInsetsDidChange
{
if (@available(iOS 11.0, *)) {
[super viewSafeAreaInsetsDidChange];
CGRect frame = _miniPlaybackView.frame;
frame.size.height = 60.0 + self.view.safeAreaInsets.bottom;
_miniPlaybackView.frame = frame;
}
}
- (VLCPlaybackController *)playbackController { - (VLCPlaybackController *)playbackController {
if (_playbackController == nil) { if (_playbackController == nil) {
_playbackController = [VLCPlaybackController sharedInstance]; _playbackController = [VLCPlaybackController sharedInstance];
...@@ -126,6 +87,7 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -126,6 +87,7 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
if (!_movieViewController) { if (!_movieViewController) {
#if TARGET_OS_IOS #if TARGET_OS_IOS
_movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil]; _movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
((VLCMovieViewController *)_movieViewController).delegate = self;
#else #else
_movieViewController = [[VLCFullscreenMovieTVViewController alloc] initWithNibName:nil bundle:nil]; _movieViewController = [[VLCFullscreenMovieTVViewController alloc] initWithNibName:nil bundle:nil];
#endif #endif
...@@ -178,7 +140,7 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -178,7 +140,7 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
- (void)closeFullscreenPlayback - (void)closeFullscreenPlayback
{ {
[self _closeFullscreenPlayback]; [self.movieViewController dismissViewControllerAnimated:[self shouldAnimate] completion:nil];
self.displayMode = VLCPlayerDisplayControllerDisplayModeMiniplayer; self.displayMode = VLCPlayerDisplayControllerDisplayModeMiniplayer;
[self _showHideMiniPlaybackView]; [self _showHideMiniPlaybackView];
} }
...@@ -298,15 +260,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -298,15 +260,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
const BOOL activePlaybackSession = playbackController.isPlaying || playbackController.willPlay; const BOOL activePlaybackSession = playbackController.isPlaying || playbackController.willPlay;
const BOOL miniPlayerVisible = miniPlaybackView.visible; const BOOL miniPlayerVisible = miniPlaybackView.visible;
const CGRect viewRect = self.view.bounds;
CGFloat miniPlayerHeight = 60.;
if (@available(iOS 11.0, *)) {
miniPlayerHeight += self.view.safeAreaInsets.bottom;
}
const CGRect miniPlayerFrameIn = CGRectMake(0., viewRect.size.height-miniPlayerHeight-self.view.layoutMargins.bottom, viewRect.size.width, miniPlayerHeight);
const CGRect miniPlayerFrameOut = CGRectMake(0., viewRect.size.height, viewRect.size.width, miniPlayerHeight);
BOOL needsShow = activePlaybackSession && !miniPlayerVisible; BOOL needsShow = activePlaybackSession && !miniPlayerVisible;
BOOL needsHide = !activePlaybackSession && miniPlayerVisible; BOOL needsHide = !activePlaybackSession && miniPlayerVisible;
...@@ -318,9 +271,18 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -318,9 +271,18 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
void (^completionBlock)(BOOL) = nil; void (^completionBlock)(BOOL) = nil;
if (needsShow) { if (needsShow) {
if (!miniPlaybackView) { if (!miniPlaybackView) {
self.miniPlaybackView = miniPlaybackView = [[VLCMiniPlaybackView alloc] initWithFrame:miniPlayerFrameOut]; self.miniPlaybackView = miniPlaybackView = [[VLCMiniPlaybackView alloc] initWithFrame:CGRectZero];
miniPlaybackView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; miniPlaybackView.translatesAutoresizingMaskIntoConstraints = NO;
miniPlaybackView.userInteractionEnabled = YES;
[self.view addSubview:miniPlaybackView]; [self.view addSubview:miniPlaybackView];
_bottomConstraint = [miniPlaybackView.topAnchor constraintEqualToAnchor:self.view.bottomAnchor];
[NSLayoutConstraint activateConstraints:
@[_bottomConstraint,
[miniPlaybackView.heightAnchor constraintEqualToConstant:60.0],
[miniPlaybackView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
[miniPlaybackView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor],
]];
[self.view layoutIfNeeded];
} }
miniPlaybackView.visible = YES; miniPlaybackView.visible = YES;
} else if (needsHide) { } else if (needsHide) {
...@@ -341,22 +303,27 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -341,22 +303,27 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
[miniPlaybackView prepareForMediaPlayback:playbackController]; [miniPlaybackView prepareForMediaPlayback:playbackController];
if (needsShow || needsHide) { if (needsShow || needsHide) {
UIViewController *childViewController = self.childViewController;
const CGRect newMiniPlayerFrame = needsHide ? miniPlayerFrameOut : miniPlayerFrameIn;
CGRect newChildViewFrame = childViewController.view.frame;
newChildViewFrame.size.height = CGRectGetMinY(newMiniPlayerFrame)-CGRectGetMinY(newChildViewFrame);
[UIView animateWithDuration:animationDuration [UIView animateWithDuration:animationDuration
delay:animationDuration delay:animationDuration
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction
animations:^{ animations:^{
miniPlaybackView.frame = newMiniPlayerFrame; self.bottomConstraint.constant = needsHide ? 0 : -_miniPlaybackView.frame.size.height -self.view.layoutMargins.bottom;
childViewController.view.frame = newChildViewFrame; [self.view layoutIfNeeded];
} }
completion:completionBlock]; completion:completionBlock];
} }
#endif #endif
} }
#pragma mark - MovieViewControllerDelegate
- (void)movieViewControllerDidSelectMinimize:(VLCMovieViewController *)movieViewController
{
[self closeFullscreenPlayback];
}
- (BOOL)movieViewControllerShouldBeDisplayed:(VLCMovieViewController *)movieViewController
{
return self.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen;
}
@end @end
...@@ -51,6 +51,12 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC ...@@ -51,6 +51,12 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
} }
func setupViewControllers() { func setupViewControllers() {
tabBarController.addChildViewController(displayController)
tabBarController.view.addSubview(displayController.view)
displayController.view.layoutMargins = UIEdgeInsets(top:0, left:0, bottom:tabBarController.tabBar.frame.size.height, right:0)
displayController.didMove(toParentViewController: tabBarController)
let videoVC = VLCMediaViewController(services: services) let videoVC = VLCMediaViewController(services: services)
//this should probably not be the delegate //this should probably not be the delegate
videoVC.delegate = self videoVC.delegate = self
...@@ -142,18 +148,12 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC ...@@ -142,18 +148,12 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate, UITabBarC
func playMedia(media: NSManagedObject) { func playMedia(media: NSManagedObject) {
//that should go into a Coordinator itself //that should go into a Coordinator itself
let displayController = VLCPlayerDisplayController()
tabBarController.addChildViewController(displayController)
tabBarController.view.addSubview(displayController.view)
displayController.view.layoutMargins = UIEdgeInsets(top:0, left:0, bottom:tabBarController.tabBar.frame.size.height, right:0)
displayController.didMove(toParentViewController: tabBarController)
displayController.displayMode = .miniplayer
let vpc = VLCPlaybackController.sharedInstance() let vpc = VLCPlaybackController.sharedInstance()
vpc?.playMediaLibraryObject(media) vpc?.playMediaLibraryObject(media)
} }
func showSortOptions() { func showSortOptions() {
//should probably be in a coordinator as well //This should be in a subclass
let sortOptionsAlertController = UIAlertController(title: NSLocalizedString("Sort by",comment: ""), message: nil, preferredStyle: .actionSheet) let sortOptionsAlertController = UIAlertController(title: NSLocalizedString("Sort by",comment: ""), message: nil, preferredStyle: .actionSheet)
let sortByNameAction = UIAlertAction(title: SortOption.alphabetically.string, style: .default) { action in let sortByNameAction = UIAlertAction(title: SortOption.alphabetically.string, style: .default) { action in
} }
......
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