Przeglądaj źródła

DropboxController: add streaming support (refs #9784)

UI yet todo
Felix Paul Kühne 11 lat temu
rodzic
commit
a85b41b8d4

+ 1 - 0
AspenProject/VLCDropboxController.h

@@ -34,5 +34,6 @@
 
 - (void)requestDirectoryListingAtPath:(NSString *)path;
 - (void)downloadFileToDocumentFolder:(DBMetadata *)file;
+- (void)streamFile:(DBMetadata *)file;
 
 @end

+ 18 - 0
AspenProject/VLCDropboxController.m

@@ -72,6 +72,12 @@
     }
 }
 
+- (void)streamFile:(DBMetadata *)file
+{
+    if (!file.isDirectory)
+        [[self restClient] loadStreamableURLForFile:file.path];
+}
+
 - (void)_triggerNextDownload
 {
     if (_listOfDropboxFilesToDownload.count > 0 && !_downloadInProgress) {
@@ -159,6 +165,18 @@
         [self.delegate currentProgressInformation:progress];
 }
 
+- (void)restClient:(DBRestClient*)restClient loadedStreamableURL:(NSURL*)url forFile:(NSString*)path
+{
+    VLCAppDelegate *appDelegate = (VLCAppDelegate *)[UIApplication sharedApplication].delegate;
+    /* DBX returns a https URL which we don't support yet. in turn, we fall back on http */
+    [appDelegate openMovieFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@%@", url.host, url.path]]];
+}
+
+- (void)restClient:(DBRestClient*)restClient loadStreamableURLFailedWithError:(NSError*)error
+{
+    APLog(@"loadStreamableURL failed with error %i", error.code);
+}
+
 #pragma mark - DBSession delegate
 
 - (void)sessionDidReceiveAuthorizationFailure:(DBSession *)session userId:(NSString *)userId