Commit 4b9996e8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

don't use the app delegate as a proxy to the playback controller

parent bbcfcdd6
......@@ -34,10 +34,6 @@ extern NSString *const VLCDropboxSessionWasAuthorized;
- (void)cleanCache;
- (void)openMediaFromManagedObject:(NSManagedObject *)file;
- (void)openMovieFromURL:(NSURL *)url;
- (void)openMovieWithExternalSubtitleFromURL:(NSURL *)url externalSubURL:(NSString *)SubtitlePath;
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
@property (nonatomic, readonly) VLCPlayerDisplayController *playerDisplayController;
......
......@@ -221,14 +221,19 @@ continueUserActivity:(NSUserActivity *)userActivity
return NO;
}
- (void)application:(UIApplication *)application didFailToContinueUserActivityWithType:(NSString *)userActivityType error:(NSError *)error
- (void)application:(UIApplication *)application
didFailToContinueUserActivityWithType:(NSString *)userActivityType
error:(NSError *)error
{
if (error.code != NSUserCancelledError){
//TODO: present alert
}
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
if ([[DBSession sharedSession] handleOpenURL:url]) {
[[NSNotificationCenter defaultCenter] postNotificationName:VLCDropboxSessionWasAuthorized object:nil];
......@@ -273,7 +278,8 @@ continueUserActivity:(NSUserActivity *)userActivity
errorCallback = [NSURL URLWithString:value];
}
if ([action isEqualToString:@"stream"] && movieURL) {
[self openMovieFromURL:movieURL successCallback:successCallback errorCallback:errorCallback];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:movieURL successCallback:successCallback errorCallback:errorCallback];
}
else if ([action isEqualToString:@"download"] && movieURL) {
[self downloadMovieFromURL:movieURL fileNameOfMedia:fileName];
......@@ -307,12 +313,16 @@ continueUserActivity:(NSUserActivity *)userActivity
alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
if (cancelled)
[self downloadMovieFromURL:url fileNameOfMedia:nil];
else
[self openMovieFromURL:url];
else {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
}
};
[alert show];
} else
[self openMovieFromURL:url];
} else {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
}
}
return YES;
}
......@@ -505,44 +515,10 @@ continueUserActivity:(NSUserActivity *)userActivity
scrollPosition:UITableViewScrollPositionNone];
}
#pragma mark - playback view handling
- (void)openMediaFromManagedObject:(NSManagedObject *)mediaObject
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playMediaLibraryObject:mediaObject];
}
- (void)openMovieFromURL:(NSURL *)url
successCallback:(NSURL *)successCallback
errorCallback:(NSURL *)errorCallback
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
vpc.url = url;
vpc.successCallback = successCallback;
vpc.errorCallback = errorCallback;
[vpc startPlayback];
}
- (void)openMovieFromURL:(NSURL *)url
{
[self openMovieFromURL:url successCallback:nil errorCallback:nil];
}
- (void)openMovieWithExternalSubtitleFromURL:(NSURL *)url externalSubURL:(NSString *)SubtitlePath
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
vpc.url = url;
vpc.pathToExternalSubtitlesFile = SubtitlePath;
[vpc startPlayback];
}
#pragma mark - watch struff
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
- (void)application:(UIApplication *)application
handleWatchKitExtensionRequest:(NSDictionary *)userInfo
reply:(void (^)(NSDictionary *))reply
{
/* dispatch background task */
__block UIBackgroundTaskIdentifier taskIdentifier = [application beginBackgroundTaskWithName:nil
......@@ -586,7 +562,8 @@ continueUserActivity:(NSUserActivity *)userActivity
return;
}
[self openMediaFromManagedObject:managedObject];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playMediaLibraryObject:managedObject];
}
- (void)setVolumeFromWatch:(VLCWatchMessage *)message
......
......@@ -12,6 +12,7 @@
#import "VLCBoxController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLCAppDelegate.h"
#import <SSKeychain/SSKeychain.h>
......@@ -178,8 +179,8 @@
[connection cancel];
/* now ask VLC to stream the URL we were just passed */
VLCAppDelegate *appDelegate = (VLCAppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:theActualURL];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:theActualURL successCallback:nil errorCallback:nil];
}
return request;
......
......@@ -13,6 +13,7 @@
#import "VLCDropboxController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLCAppDelegate.h"
@interface VLCDropboxController ()
......@@ -195,8 +196,8 @@
- (void)restClient:(DBRestClient*)restClient loadedStreamableURL:(NSURL*)url forFile:(NSString*)path
{
VLCAppDelegate *appDelegate = (VLCAppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:url];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
}
- (void)restClient:(DBRestClient*)restClient loadStreamableURLFailedWithError:(NSError*)error
......
......@@ -17,6 +17,7 @@
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
#import "VLCStatusLabel.h"
#import "VLCPlaybackController.h"
#import "WhiteRaccoon.h"
......@@ -113,8 +114,8 @@
NSURL *URLToPlay = [NSURL URLWithString:[[@"ftp" stringByAppendingFormat:@"://%@%@/%@/%@", [self _credentials], _ftpServerAddress, _ftpServerPath, fileName] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:URLToPlay externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:URLToPlay subtitlesFilePath:URLofSubtitle];
}
- (NSArray *)_searchSubtitle:(NSString *)url
......
......@@ -13,6 +13,7 @@
#import "VLCGoogleDriveController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLCAppDelegate.h"
@interface VLCGoogleDriveController ()
......@@ -152,10 +153,10 @@
- (void)streamFile:(GTLDriveFile *)file
{
VLCAppDelegate *appDelegate = (VLCAppDelegate *)[UIApplication sharedApplication].delegate;
NSString *token = ((GTMOAuth2Authentication *)self.driveService.authorizer).accessToken;
NSString *downloadString = [file.downloadUrl stringByAppendingString:[NSString stringWithFormat:@"&access_token=%@",token]];
[appDelegate openMovieFromURL:[NSURL URLWithString:downloadString]];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL URLWithString:downloadString] successCallback:nil errorCallback:nil];
}
- (void)_triggerNextDownload
......
......@@ -15,7 +15,7 @@
#import "VLCPlexParser.h"
#import "VLCPlexWebAPI.h"
#import "VLCNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCPlaylistViewController.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
......@@ -288,8 +288,8 @@
NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:firstObject[@"keyMedia"]]];
if (itemURL) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:itemURL externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
}
} else {
VLCLocalPlexFolderListViewController *targetViewController = [[VLCLocalPlexFolderListViewController alloc] initWithPlexServer:_PlexServerName serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:newPath authentification:_PlexAuthentification];
......@@ -327,8 +327,8 @@
NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[firstObject objectForKey:@"keyMedia"]]];
if (itemURL) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:itemURL externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
}
}
}
......
......@@ -13,7 +13,7 @@
#import "VLCOneDriveTableViewController.h"
#import "VLCOneDriveController.h"
#import "VLCCloudStorageTableViewCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCOneDriveController.h"
#import "VLCProgressView.h"
#import "UIDevice+VLC.h"
......@@ -104,8 +104,8 @@
} else {
/* stream file */
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
VLCAppDelegate *appDelegate = (VLCAppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:url];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
}
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
......
......@@ -13,7 +13,7 @@
*****************************************************************************/
#import "VLCOpenNetworkStreamViewController.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCPlaylistViewController.h"
#import "VLCMenuTableViewController.h"
#import "UIDevice+VLC.h"
......@@ -249,7 +249,8 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
if (self.ScanSubToggleSwitch.on)
URLofSubtitle = [self _checkURLofSubtitle:url];
[(VLCAppDelegate*)[UIApplication sharedApplication].delegate openMovieWithExternalSubtitleFromURL:[NSURL URLWithString:url] externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL URLWithString:url] subtitlesFilePath:URLofSubtitle];
}
- (NSString *)_checkURLofSubtitle:(NSString *)url
......
......@@ -92,5 +92,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)scheduleSleepTimerWithInterval:(NSTimeInterval)timeInterval;
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(int)index;
- (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback;
- (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath;
@end
......@@ -160,6 +160,35 @@ NSString *const VLCPlaybackControllerPlaybackDidFail = @"VLCPlaybackControllerPl
}
}
- (void)playURL:(NSURL *)url successCallback:(NSURL*)successCallback errorCallback:(NSURL *)errorCallback
{
self.url = url;
self.successCallback = successCallback;
self.errorCallback = errorCallback;
if (self.activePlaybackSession) {
self.sessionWillRestart = YES;
[self stopPlayback];
} else {
self.sessionWillRestart = NO;
[self startPlayback];
}
}
- (void)playURL:(NSURL *)url subtitlesFilePath:(NSString *)subsFilePath
{
self.url = url;
self.pathToExternalSubtitlesFile = subsFilePath;
if (self.activePlaybackSession) {
self.sessionWillRestart = YES;
[self stopPlayback];
} else {
self.sessionWillRestart = NO;
[self startPlayback];
}
}
- (void)startPlayback
{
if (_playerIsSetup)
......
......@@ -26,6 +26,7 @@
#import "LXReorderableCollectionViewFlowLayout.h"
#import "VLCOpenInActivity.h"
#import "VLCNavigationController.h"
#import "VLCPlaybackController+MediaLibrary.h"
#import <AssetsLibrary/AssetsLibrary.h>
......@@ -300,8 +301,10 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
[self reloadViews];
return;
} else
[(VLCAppDelegate*)[UIApplication sharedApplication].delegate openMediaFromManagedObject:mediaObject];
} else {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playMediaLibraryObject:mediaObject];
}
}
- (void)removeMediaObject:(id)managedObject updateDatabase:(BOOL)updateDB
......
......@@ -12,7 +12,8 @@
#import "VLCPlexMediaInformationViewController.h"
#import "VLCPlexParser.h"
#import "VLCPlexWebAPI.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
......@@ -131,8 +132,8 @@
NSURL *itemURL = [NSURL URLWithString:[_PlexWebAPI urlAuth:firstObject[@"keyMedia"] autentification:_PlexAuthentification]];
if (itemURL) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:itemURL externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
}
}
}
......
......@@ -13,7 +13,7 @@
*****************************************************************************/
#import "VLCServerListViewController.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "UPnPManager.h"
#import "VLCNetworkListCell.h"
......@@ -452,11 +452,12 @@
case 6:
{
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
VLCMedia *cellMedia = [_sapDiscoverer.discoveredMedia mediaAtIndex:row];
VLCMediaType mediaType = cellMedia.mediaType;
if (mediaType != VLCMediaTypeDirectory && mediaType != VLCMediaTypeDisc)
[appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
if (mediaType != VLCMediaTypeDirectory && mediaType != VLCMediaTypeDisc) {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url] successCallback:nil errorCallback:nil];
}
break;
}
......
......@@ -13,7 +13,7 @@
#import "VLCSharedLibraryListViewController.h"
#import "VLCSharedLibraryParser.h"
#import "VLCNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCPlaylistViewController.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
......@@ -228,8 +228,8 @@
NSURL *itemURL = [NSURL URLWithString:[selectedObject objectForKey:@"pathfile"]];
if (itemURL) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:itemURL externalSubURL:URLofSubtitle];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
......
......@@ -13,9 +13,10 @@
*****************************************************************************/
#import "VLCUPnPServerListViewController.h"
#import "VLCDownloadViewController.h"
#import "VLCNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaybackController.h"
#import "VLCStatusLabel.h"
#import "NSString+SupportedMedia.h"
......@@ -262,8 +263,8 @@
itemURL = [NSURL URLWithString:uriCollectionObjects[correctIndex]];
}
if (itemURL) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:itemURL];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:itemURL successCallback:nil errorCallback:nil];
}
}
}
......@@ -456,8 +457,8 @@
NSString *itemURLString = uriCollectionObjects[buttonIndex];
if ([itemURLString length]) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:[NSURL URLWithString:itemURLString]];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:[NSURL URLWithString:itemURLString] successCallback:nil errorCallback:nil];
}
}
}
......
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