Commit bb0afb92 authored by Felix Paul Kühne's avatar Felix Paul Kühne

VPDC: convert pseudo singleton to an explicit one

parent 077e9699
......@@ -19,7 +19,6 @@
#import "VLCWatchCommunication.h"
@class VLCLibraryViewController;
@class VLCPlayerDisplayController;
extern NSString *const VLCDropboxSessionWasAuthorized;
......@@ -27,8 +26,6 @@ extern NSString *const VLCDropboxSessionWasAuthorized;
@property (nonatomic, readonly) VLCLibraryViewController *libraryViewController;
@property (nonatomic, readonly) VLCPlayerDisplayController *playerDisplayController;
@property (nonatomic, readonly) VLCWatchCommunication *watchCommunication;
@property (nonatomic, strong) UIWindow *window;
......
......@@ -130,10 +130,10 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
VLCNavigationController *navCon = [[VLCNavigationController alloc] initWithRootViewController:_libraryViewController];
sidebarVC.contentViewController = navCon;
_playerDisplayController = [[VLCPlayerDisplayController alloc] init];
_playerDisplayController.childViewController = sidebarVC.fullViewController;
VLCPlayerDisplayController *playerDisplayController = [VLCPlayerDisplayController sharedInstance];
playerDisplayController.childViewController = sidebarVC.fullViewController;
self.window.rootViewController = _playerDisplayController;
self.window.rootViewController = playerDisplayController;
[self.window makeKeyAndVisible];
[self validatePasscode];
......@@ -414,7 +414,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
_passcodeValidated = YES;
[self.libraryViewController updateViewContents];
if ([VLCPlaybackController sharedInstance].isPlaying)
[_playerDisplayController pushPlaybackView];
[[VLCPlayerDisplayController sharedInstance] pushPlaybackView];
}
- (BOOL)passcodeValidated
......@@ -427,7 +427,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
VLCKeychainCoordinator *keychainCoordinator = [VLCKeychainCoordinator defaultCoordinator];
if (!_passcodeValidated && [keychainCoordinator passcodeLockEnabled]) {
[_playerDisplayController dismissPlaybackView];
[[VLCPlayerDisplayController sharedInstance] dismissPlaybackView];
[keychainCoordinator validatePasscode];
} else
......
......@@ -12,9 +12,8 @@
#import "VLCMiniPlaybackView.h"
#import "VLCPlaybackController.h"
#import "VLCAppDelegate.h"
#import "VLCLibraryViewController.h"
#import "VLCPlayerDisplayController.h"
#import "VLCLibraryViewController.h"
#import "VLCKeychainCoordinator.h"
@interface VLCMiniPlaybackView () <UIGestureRecognizerDelegate>
......@@ -130,7 +129,7 @@
- (void)appBecameActive:(NSNotification *)aNotification
{
VLCPlayerDisplayController *pdc = [(VLCAppDelegate *)[UIApplication sharedApplication].delegate playerDisplayController];
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeMiniplayer) {
VLCPlaybackController *vpc = self.playbackController;
[vpc recoverDisplayedMetadata];
......@@ -190,10 +189,9 @@
- (void)prepareForMediaPlayback:(VLCPlaybackController *)controller
{
self.playbackController = playbackController;
[self updatePlayPauseButton];
playbackController.delegate = self;
[playbackController recoverDisplayedMetadata];
controller.delegate = self;
[controller recoverDisplayedMetadata];
}
- (void)mediaPlayerStateChanged:(VLCMediaPlayerState)currentState
......@@ -227,7 +225,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
_videoView = nil;
}
VLCPlayerDisplayController *pdc = [(VLCAppDelegate *)[UIApplication sharedApplication].delegate playerDisplayController];
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeMiniplayer) {
_videoView = [[UIView alloc] initWithFrame:_artworkView.frame];
[_videoView setClipsToBounds:YES];
......
......@@ -497,7 +497,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
[self setControlsHidden:YES animated:animated];
[self setControlsHidden:YES animated:flag];
[super dismissViewControllerAnimated:flag completion:completion];
}
......@@ -1305,10 +1305,10 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
if ([vpc.mediaPlayer isPlaying]) {
[vpc.listPlayer pause];
[self.statusLabel showStatusMessage:@" ▌▌" forPlaybackController:nil];
[self.statusLabel showStatusMessage:@" ▌▌"];
} else {
[vpc.listPlayer play];
[self.statusLabel showStatusMessage:@" ►" forPlaybackController:nil];
[self.statusLabel showStatusMessage:@" ►"];
}
}
......@@ -1511,7 +1511,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)appBecameActive:(NSNotification *)aNotification
{
VLCPlayerDisplayController *pdc = [(VLCAppDelegate *)[UIApplication sharedApplication].delegate playerDisplayController];
VLCPlayerDisplayController *pdc = [VLCPlayerDisplayController sharedInstance];
if (pdc.displayMode == VLCPlayerDisplayControllerDisplayModeFullscreen) {
VLCPlaybackController *vpc = self.playbackController;
[vpc recoverDisplayedMetadata];
......
......@@ -25,6 +25,9 @@ typedef NS_ENUM(NSUInteger, VLCPlayerDisplayControllerDisplayMode) {
@end
@interface VLCPlayerDisplayController : UIViewController
+ (VLCPlayerDisplayController *)sharedInstance;
@property (nonatomic, strong) UIViewController *childViewController;
@property (nonatomic, assign) VLCPlayerDisplayControllerDisplayMode displayMode;
......
......@@ -13,10 +13,10 @@
#import "VLCPlayerDisplayController.h"
#import "VLCPlaybackController.h"
#import "VLCPlaybackNavigationController.h"
#import "VLCMiniPlaybackView.h"
#if TARGET_OS_IOS
#import "VLCMovieViewController.h"
#import "VLCMiniPlaybackView.h"
#endif
static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDisplayControllerDisplayMode";
......@@ -28,6 +28,18 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
@implementation VLCPlayerDisplayController
+ (VLCPlayerDisplayController *)sharedInstance
{
static VLCPlayerDisplayController *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCPlayerDisplayController new];
});
return sharedInstance;
}
+ (void)initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:@{VLCPlayerDisplayControllerDisplayModeKey : @(VLCPlayerDisplayControllerDisplayModeFullscreen)}];
......@@ -281,9 +293,7 @@ static inline void commonSetup(VLCPlayerDisplayController *self)
void (^completionBlock)(BOOL) = nil;
if (needsShow) {
if (!miniPlaybackView) {
#if TARGET_OS_IOS
self.miniPlaybackView = miniPlaybackView = [[VLCMiniPlaybackView alloc] initWithFrame:miniPlayerFrameOut];
#endif
miniPlaybackView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:miniPlaybackView];
}
......
......@@ -11,12 +11,8 @@
#import <UIKit/UIKit.h>
@class VLCPlayerDisplayController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, readonly) VLCPlayerDisplayController *playerDisplayController;
@end
......@@ -34,7 +34,7 @@
NSDictionary *appDefaults = @{kVLCSettingContinueAudioInBackgroundKey : @(YES),
kVLCSettingStretchAudio : @(NO),
kVLCSettingVideoFullscreenPlayback : @(YES),
kVLCSettingVideoFullscreenPlayback : @(NO),
kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue,
kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef,
kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue,
......@@ -61,10 +61,9 @@
_mainViewController.tabBar.backgroundColor = [UIColor VLCOrangeTintColor];
_mainViewController.viewControllers = @[_sharesVC, _localNetworkVC, _openNetworkVC];
_playerDisplayController = [[VLCPlayerDisplayController alloc] init];
_playerDisplayController.childViewController = _mainViewController;
self.window.rootViewController = _playerDisplayController;
VLCPlayerDisplayController *playerDisplayController = [VLCPlayerDisplayController sharedInstance];
playerDisplayController.childViewController = _mainViewController;
self.window.rootViewController = playerDisplayController;
[self.window makeKeyAndVisible];
return YES;
......
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