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

Add 'Play All' feature to OneDrive

(cherry picked from commit 5276936e)
parent e247ead5
......@@ -114,6 +114,12 @@
}
#pragma mark - file management
- (BOOL)canPlayAll
{
return NO;
}
- (void)requestDirectoryListingAtPath:(NSString *)path
{
//we entered a different folder so discard all current files
......
......@@ -27,6 +27,7 @@
@property (nonatomic, weak) id<VLCCloudStorageDelegate> delegate;
@property (nonatomic, readwrite) BOOL isAuthorized;
@property (nonatomic, readonly) NSArray *currentListFiles;
@property (nonatomic, readonly) BOOL canPlayAll;
+ (instancetype)sharedInstance;
......
......@@ -28,6 +28,7 @@
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
- (IBAction)loginAction:(id)sender;
- (IBAction)playAllAction:(id)sender;
- (void)requestInformationForCurrentPath;
- (void)showLoginPanel;
......
......@@ -190,7 +190,12 @@
- (void)updateViewAfterSessionChange
{
self.navigationItem.rightBarButtonItem = _logoutButton;
if (self.controller.canPlayAll) {
self.navigationItem.rightBarButtonItems = @[_logoutButton, [UIBarButtonItem themedPlayAllButtonWithTarget:self andSelector:@selector(playAllAction:)]];
} else {
self.navigationItem.rightBarButtonItem = _logoutButton;
}
if(_authorizationInProgress) {
if (self.loginToCloudStorageView.superview) {
[self.loginToCloudStorageView removeFromSuperview];
......@@ -221,5 +226,8 @@
{
}
- (IBAction)playAllAction:(id)sender
{
}
@end
......@@ -110,6 +110,12 @@
}
#pragma mark - file management
- (BOOL)canPlayAll
{
return NO;
}
- (void)requestDirectoryListingAtPath:(NSString *)path
{
if (self.isAuthorized)
......
......@@ -126,6 +126,12 @@
}
#pragma mark - file management
- (BOOL)canPlayAll
{
return NO;
}
- (void)requestDirectoryListingAtPath:(NSString *)path
{
if (self.isAuthorized) {
......
......@@ -233,6 +233,11 @@
#pragma mark - file handling
- (BOOL)canPlayAll
{
return YES;
}
- (void)downloadObject:(VLCOneDriveObject *)object
{
if (object == nil)
......
......@@ -111,15 +111,62 @@
[_oneDriveController loadCurrentFolder];
self.title = selectedObject.name;
} else {
/* stream file */
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
if (![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem]) {
/* stream file */
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
[vpc playURL:url successCallback:nil errorCallback:nil];
} else {
NSUInteger count = folderItems.count;
NSMutableArray *mediaItems = [[NSMutableArray alloc] init];
NSInteger firstIndex = 0;
for (NSInteger x = count - 1; x > -1; x--) {
VLCOneDriveObject *iter = folderItems[x];
if (iter.isFolder)
continue;
NSURL *url = [NSURL URLWithString:iter.downloadPath];
if (url) {
[mediaItems addObject:[VLCMedia mediaWithURL:url]];
if (iter == selectedObject) {
firstIndex = mediaItems.count;
}
}
}
if (mediaItems.count > 0) {
NSLog(@"%s: %@ %li", __PRETTY_FUNCTION__, mediaItems, firstIndex);
[vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:firstIndex];
}
}
}
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (void)playAllAction:(id)sender
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSArray *folderItems = _oneDriveController.currentFolder.items;
NSUInteger count = folderItems.count;
NSMutableArray *mediaItems = [[NSMutableArray alloc] init];
for (NSInteger x = count - 1; x > -1; x--) {
VLCOneDriveObject *iter = folderItems[x];
if (iter.isFolder)
continue;
NSURL *url = [NSURL URLWithString:iter.downloadPath];
if (url) {
[mediaItems addObject:[VLCMedia mediaWithURL:url]];
}
}
if (mediaItems.count > 0) {
[vpc playMediaList:[[VLCMediaList alloc] initWithArray:mediaItems] firstIndex:0];
}
}
#pragma mark - login dialog
- (void)loginAction:(id)sender
......
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