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 @@
- (void)disableIdleTimer;
- (void)activateIdleTimer;
- (void)openMediaFromManagedObject:(NSManagedObject *)file;
- (void)openMovieFromURL:(NSURL *)url;
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
@property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic, readonly) VLCDownloadViewController *downloadViewController;
......
......@@ -27,6 +27,7 @@
VLCDropboxTableViewController *_dropboxTableViewController;
VLCDownloadViewController *_downloadViewController;
int _idleCounter;
VLCMovieViewController *_movieViewController;
}
@property (nonatomic) BOOL passcodeValidated;
......@@ -288,4 +289,35 @@
[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
......@@ -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"])) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
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];
[appDelegate openMovieFromURL:itemURL];
}
}
} else if (_serverType == kVLCServerTypeFTP) {
......@@ -350,8 +343,7 @@
- (void)_openURLStringAndDismiss:(NSString *)url
{
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[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]];
}
@end
......@@ -241,14 +241,7 @@
_loginViewController.serverAddressField.text = @"";
} else if (section == 2) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
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];
[appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
}
}
......
......@@ -674,7 +674,7 @@
- (IBAction)closePlayback:(id)sender
{
[self setControlsHidden:NO animated:NO];
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)positionSliderAction:(UISlider *)sender
......
......@@ -174,7 +174,7 @@
{
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[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
......
......@@ -18,18 +18,15 @@ typedef enum {
VLCLibraryModeAllSeries = 2
} VLCLibraryMode;
@class VLCMovieViewController;
@class EmptyLibraryView;
@interface VLCPlaylistViewController : UIViewController <UITabBarDelegate, UIPopoverControllerDelegate>
@property (nonatomic, strong) VLCMovieViewController *movieViewController;
@property (nonatomic, strong) UIViewController *menuViewController;
- (IBAction)leftButtonAction:(id)sender;
- (void)updateViewContents;
- (void)openMovieFromURL:(NSURL *)url;
- (void)removeMediaObject:(MLFile *)mediaObject;
- (void)setLibraryMode:(VLCLibraryMode)mode;
......
......@@ -179,19 +179,8 @@
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
self.title = [(MLShow*)mediaObject name];
[self reloadViews];
} else {
if (!self.movieViewController)
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];
}
} else
[(VLCAppDelegate*)[UIApplication sharedApplication].delegate openMediaFromManagedObject:mediaObject];
}
- (void)removeMediaObject:(MLFile *)mediaObject
......@@ -472,17 +461,6 @@
#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
{
_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