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

Move playback view controller handling etc. from the library view to the app delegate

This makes a bit more sense, allows the removal of quite a few hacks and allows users of the local network tab to stay in their current directory instead of being thrown back to the media library.
parent 1e79d63f
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
- (void)disableIdleTimer; - (void)disableIdleTimer;
- (void)activateIdleTimer; - (void)activateIdleTimer;
- (void)openMediaFromManagedObject:(NSManagedObject *)file;
- (void)openMovieFromURL:(NSURL *)url;
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController; @property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
@property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController; @property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic, readonly) VLCDownloadViewController *downloadViewController; @property (nonatomic, readonly) VLCDownloadViewController *downloadViewController;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
VLCDropboxTableViewController *_dropboxTableViewController; VLCDropboxTableViewController *_dropboxTableViewController;
VLCDownloadViewController *_downloadViewController; VLCDownloadViewController *_downloadViewController;
int _idleCounter; int _idleCounter;
VLCMovieViewController *_movieViewController;
} }
@property (nonatomic) BOOL passcodeValidated; @property (nonatomic) BOOL passcodeValidated;
...@@ -288,4 +289,35 @@ ...@@ -288,4 +289,35 @@
[UIApplication sharedApplication].idleTimerDisabled = NO; [UIApplication sharedApplication].idleTimerDisabled = NO;
} }
#pragma mark - playback view handling
- (void)openMediaFromManagedObject:(NSManagedObject *)mediaObject
{
if (!_movieViewController)
_movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
if ([mediaObject isKindOfClass:[MLFile class]])
_movieViewController.mediaItem = (MLFile *)mediaObject;
else if ([mediaObject isKindOfClass:[MLAlbumTrack class]])
_movieViewController.mediaItem = [(MLAlbumTrack*)mediaObject files].anyObject;
else if ([mediaObject isKindOfClass:[MLShowEpisode class]])
_movieViewController.mediaItem = [(MLShowEpisode*)mediaObject files].anyObject;
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_movieViewController];
navCon.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
- (void)openMovieFromURL:(NSURL *)url
{
if (!_movieViewController)
_movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
_movieViewController.url = url;
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_movieViewController];
navCon.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
@end @end
...@@ -217,14 +217,7 @@ ...@@ -217,14 +217,7 @@
if (itemURL && ([itemURL.scheme isEqualToString:@"http"] || [itemURL.scheme isEqualToString:@"rtsp"] || [itemURL.scheme isEqualToString:@"rtp"] || [itemURL.scheme isEqualToString:@"mms"] || [itemURL.scheme isEqualToString:@"mmsh"])) { if (itemURL && ([itemURL.scheme isEqualToString:@"http"] || [itemURL.scheme isEqualToString:@"rtsp"] || [itemURL.scheme isEqualToString:@"rtp"] || [itemURL.scheme isEqualToString:@"mms"] || [itemURL.scheme isEqualToString:@"mmsh"])) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate; VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:itemURL];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:appDelegate.playlistViewController];
[navController loadTheme];
appDelegate.revealController.contentViewController = navController;
[appDelegate.revealController toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
[appDelegate.playlistViewController performSelector:@selector(openMovieFromURL:) withObject:itemURL afterDelay:kGHRevealSidebarDefaultAnimationDuration];
} }
} }
} else if (_serverType == kVLCServerTypeFTP) { } else if (_serverType == kVLCServerTypeFTP) {
...@@ -350,8 +343,7 @@ ...@@ -350,8 +343,7 @@
- (void)_openURLStringAndDismiss:(NSString *)url - (void)_openURLStringAndDismiss:(NSString *)url
{ {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate; VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone]; [appDelegate openMovieFromURL:[NSURL URLWithString:url]];
[appDelegate.playlistViewController performSelector:@selector(openMovieFromURL:) withObject:[NSURL URLWithString:url] afterDelay:kGHRevealSidebarDefaultAnimationDuration];
} }
@end @end
...@@ -241,14 +241,7 @@ ...@@ -241,14 +241,7 @@
_loginViewController.serverAddressField.text = @""; _loginViewController.serverAddressField.text = @"";
} else if (section == 2) { } else if (section == 2) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate; VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:appDelegate.playlistViewController];
[navController loadTheme];
appDelegate.revealController.contentViewController = navController;
[appDelegate.revealController toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
[appDelegate.playlistViewController performSelector:@selector(openMovieFromURL:) withObject:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url] afterDelay:kGHRevealSidebarDefaultAnimationDuration];
} }
} }
......
...@@ -674,7 +674,7 @@ ...@@ -674,7 +674,7 @@
- (IBAction)closePlayback:(id)sender - (IBAction)closePlayback:(id)sender
{ {
[self setControlsHidden:NO animated:NO]; [self setControlsHidden:NO animated:NO];
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController dismissViewControllerAnimated:YES completion:nil];
} }
- (IBAction)positionSliderAction:(UISlider *)sender - (IBAction)positionSliderAction:(UISlider *)sender
......
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
{ {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate; VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone]; [appDelegate.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
[appDelegate.playlistViewController performSelector:@selector(openMovieFromURL:) withObject:[NSURL URLWithString:url] afterDelay:kGHRevealSidebarDefaultAnimationDuration]; [appDelegate openMovieFromURL:[NSURL URLWithString:url]];
} }
#pragma mark - text view delegate #pragma mark - text view delegate
......
...@@ -18,18 +18,15 @@ typedef enum { ...@@ -18,18 +18,15 @@ typedef enum {
VLCLibraryModeAllSeries = 2 VLCLibraryModeAllSeries = 2
} VLCLibraryMode; } VLCLibraryMode;
@class VLCMovieViewController;
@class EmptyLibraryView; @class EmptyLibraryView;
@interface VLCPlaylistViewController : UIViewController <UITabBarDelegate, UIPopoverControllerDelegate> @interface VLCPlaylistViewController : UIViewController <UITabBarDelegate, UIPopoverControllerDelegate>
@property (nonatomic, strong) VLCMovieViewController *movieViewController;
@property (nonatomic, strong) UIViewController *menuViewController; @property (nonatomic, strong) UIViewController *menuViewController;
- (IBAction)leftButtonAction:(id)sender; - (IBAction)leftButtonAction:(id)sender;
- (void)updateViewContents; - (void)updateViewContents;
- (void)openMovieFromURL:(NSURL *)url;
- (void)removeMediaObject:(MLFile *)mediaObject; - (void)removeMediaObject:(MLFile *)mediaObject;
- (void)setLibraryMode:(VLCLibraryMode)mode; - (void)setLibraryMode:(VLCLibraryMode)mode;
......
...@@ -179,19 +179,8 @@ ...@@ -179,19 +179,8 @@
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")]; [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
self.title = [(MLShow*)mediaObject name]; self.title = [(MLShow*)mediaObject name];
[self reloadViews]; [self reloadViews];
} else { } else
if (!self.movieViewController) [(VLCAppDelegate*)[UIApplication sharedApplication].delegate openMediaFromManagedObject:mediaObject];
self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
if ([mediaObject isKindOfClass:[MLFile class]])
self.movieViewController.mediaItem = (MLFile *)mediaObject;
else if ([mediaObject isKindOfClass:[MLAlbumTrack class]])
self.movieViewController.mediaItem = [(MLAlbumTrack*)mediaObject files].anyObject;
else if ([mediaObject isKindOfClass:[MLShowEpisode class]])
self.movieViewController.mediaItem = [(MLShowEpisode*)mediaObject files].anyObject;
[self.navigationController pushViewController:self.movieViewController animated:YES];
}
} }
- (void)removeMediaObject:(MLFile *)mediaObject - (void)removeMediaObject:(MLFile *)mediaObject
...@@ -472,17 +461,6 @@ ...@@ -472,17 +461,6 @@
#pragma mark - coin coin #pragma mark - coin coin
- (void)openMovieFromURL:(NSURL *)url
{
if (!self.movieViewController)
self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
if (self.navigationController.topViewController != self.movieViewController)
[self.navigationController pushViewController:self.movieViewController animated:YES];
self.movieViewController.url = url;
}
- (void)setLibraryMode:(VLCLibraryMode)mode - (void)setLibraryMode:(VLCLibraryMode)mode
{ {
_libraryMode = mode; _libraryMode = mode;
......
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