Commit ea17df6a authored by Carola Nitz's avatar Carola Nitz

GDrive: added streaming

parent 423eda37
......@@ -40,6 +40,7 @@
- (void)logout;
- (void)requestDirectoryListingWithFolderId:(NSString *)folderId;
- (BOOL)hasMoreFiles;
- (void)streamFile:(GTLDriveFile *)file;
- (void)downloadFileToDocumentFolder:(GTLDriveFile *)file;
@end
......@@ -147,6 +147,14 @@
}];
}
- (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]];
}
- (void)_triggerNextDownload
{
if (_listOfGoogleDriveFilesToDownload.count > 0 && !_downloadInProgress) {
......
......@@ -214,7 +214,6 @@
cell = [VLCCloudStorageTableViewCell cellWithReuseIdentifier:CellIdentifier];
cell.driveFile = _googleDriveController.currentListFiles[indexPath.row];
cell.downloadButton.hidden = YES;
cell.delegate = self;
return cell;
......@@ -231,8 +230,7 @@
{
_selectedFile = _googleDriveController.currentListFiles[indexPath.row];
if (![_selectedFile.mimeType isEqualToString:@"application/vnd.google-apps.folder"]) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", @"") message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", @""), _selectedFile.title, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", @""), nil];
[alert show];
[_googleDriveController streamFile:_selectedFile];
} else {
/* dive into subdirectory */
if (![_currentFolderId isEqualToString:@""])
......@@ -243,6 +241,15 @@
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (void)triggerDownloadForCell:(VLCCloudStorageTableViewCell *)cell
{
_selectedFile = _googleDriveController.currentListFiles[[self.tableView indexPathForCell:cell].row];
/* selected item is a proper file, ask the user if s/he wants to download it */
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", @"") message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", @""), _selectedFile.title, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", @""), nil];
[alert show];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSInteger currentOffset = scrollView.contentOffset.y;
......
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