Explorar el Código

OneDrive: expose more available metadata

Felix Paul Kühne hace 10 años
padre
commit
924b63ef51

+ 18 - 2
Sources/VLCCloudStorageTableViewCell.m

@@ -152,10 +152,26 @@
             self.thumbnailView.image = [UIImage imageNamed:@"folder"];
         } else {
             self.titleLabel.text = self.oneDriveFile.name;
-            self.subtitleLabel.text = (self.oneDriveFile.size > 0) ? [NSByteCountFormatter stringFromByteCount:[self.oneDriveFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]: @"";
+            NSMutableString *subtitle = [[NSMutableString alloc] init];
+            if (self.oneDriveFile.size > 0) {
+                [subtitle appendString:[NSByteCountFormatter stringFromByteCount:[self.oneDriveFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]];
+                if (self.oneDriveFile.duration > 0) {
+                    VLCTime *time = [VLCTime timeWithNumber:self.oneDriveFile.duration];
+                    [subtitle appendFormat:@" — %@", [time verboseStringValue]];
+                }
+            } else if (self.oneDriveFile.duration > 0) {
+                VLCTime *time = [VLCTime timeWithNumber:self.oneDriveFile.duration];
+                [subtitle appendString:[time verboseStringValue]];
+            }
+            self.subtitleLabel.text = subtitle;
             self.titleLabel.hidden = self.subtitleLabel.hidden = NO;
             self.folderTitleLabel.hidden = YES;
-            self.thumbnailView.image = [UIImage imageNamed:@"blank"];
+            if (self.oneDriveFile.isAudio)
+                self.thumbnailView.image = [UIImage imageNamed:@"audio"];
+            else if (self.oneDriveFile.isVideo)
+                self.thumbnailView.image = [UIImage imageNamed:@"movie"];
+            else
+                self.thumbnailView.image = [UIImage imageNamed:@"blank"];
         }
     }
     //we don't have streaming for box yet

+ 13 - 15
Sources/VLCOneDriveController.m

@@ -21,7 +21,7 @@
 /* include private API headers */
 #import <LiveSDK/LiveApiHelper.h>
 
-@interface VLCOneDriveController () <LiveAuthDelegate, LiveDownloadOperationDelegate, LiveOperationDelegate, VLCOneDriveObjectDelegate>
+@interface VLCOneDriveController () <LiveAuthDelegate, LiveDownloadOperationDelegate, VLCOneDriveObjectDelegate>
 {
     LiveConnectClient *_liveClient;
     NSArray *_liveScopes;
@@ -114,6 +114,16 @@
     }
 }
 
+- (void)liveOperationSucceeded:(LiveDownloadOperation *)operation
+{
+    APLog(@"ODC: liveOperationSucceeded (%@)", operation.userState);
+}
+
+- (void)liveOperationFailed:(NSError *)error operation:(LiveDownloadOperation *)operation
+{
+    APLog(@"ODC: liveOperationFailed %@ (%@)", error, operation.userState);
+}
+
 #pragma mark - listing
 
 - (void)loadTopLevelFolder
@@ -139,15 +149,6 @@
     }
 }
 
-- (void)liveOperationSucceeded:(LiveOperation *)operation
-{
-    NSLog(@"%@", operation);
-}
-
-- (void)liveOperationFailed:(NSError *)error operation:(LiveOperation *)operation
-{
-}
-
 #pragma mark - file handling
 
 - (void)downloadFileWithPath:(NSString *)path
@@ -168,15 +169,13 @@
 
 - (void)folderContentLoaded:(VLCOneDriveObject *)sender
 {
-    NSLog(@"odc: foldercontent loaded: %@", [sender name]);
-
     if (self.delegate)
         [self.delegate performSelector:@selector(mediaListUpdated)];
 }
 
 - (void)folderContentLoadingFailed:(NSError *)error sender:(VLCOneDriveObject *)sender
 {
-    NSLog(@"folder content loading failed %@", error);
+    APLog(@"folder content loading failed %@", error);
 }
 
 - (void)fileContentLoaded:(VLCOneDriveObject *)sender
@@ -185,12 +184,11 @@
 
 - (void)fileContentLoadingFailed:(NSError *)error sender:(VLCOneDriveObject *)sender
 {
-    NSLog(@"file content loading failed %@", error);
+    APLog(@"file content loading failed %@", error);
 }
 
 - (void)fullFolderTreeLoaded:(VLCOneDriveObject *)sender
 {
-    NSLog(@"fullFolderTreeLoaded");
     if (self.delegate)
         [self.delegate performSelector:@selector(mediaListUpdated)];
 }

+ 2 - 0
Sources/VLCOneDriveObject.h

@@ -40,6 +40,8 @@
 @property (strong, nonatomic) NSNumber *duration;
 @property (strong, nonatomic) NSString *thumbnailURL;
 @property (readonly, nonatomic) BOOL isFolder;
+@property (readonly, nonatomic) BOOL isVideo;
+@property (readonly, nonatomic) BOOL isAudio;
 
 @property (strong, nonatomic) NSArray *folders;
 @property (strong, nonatomic) NSArray *files;

+ 10 - 4
Sources/VLCOneDriveObject.m

@@ -21,6 +21,16 @@
     return [self.type isEqual:@"folder"] || [self.type isEqual:@"album"];
 }
 
+- (BOOL)isVideo
+{
+    return [self.type isEqual:@"video"];
+}
+
+- (BOOL)isAudio
+{
+    return [self.type isEqual:@"audio"];
+}
+
 - (NSString *)filesPath
 {
     return [self.objectId stringByAppendingString:@"/files"];
@@ -125,10 +135,6 @@
             [items addObject:oneDriveObject];
         }
 
-        NSLog(@"we found %i items", items.count);
-        for (NSUInteger x = 0; x < items.count; x++)
-            NSLog(@"%@", [items[x] name]);
-
         self.folders = subFolders;
         self.files = folderFiles;
         self.items = items;

+ 6 - 2
Sources/VLCOneDriveTableViewController.m

@@ -87,10 +87,13 @@
 - (IBAction)goBack:(id)sender
 {
     if (_oneDriveController.rootFolder != _oneDriveController.currentFolder) {
-        if ([_oneDriveController.rootFolder.name isEqualToString:_oneDriveController.currentFolder.parent.name])
+        if ([_oneDriveController.rootFolder.name isEqualToString:_oneDriveController.currentFolder.parent.name]) {
             _oneDriveController.currentFolder = nil;
-        else
+            self.title = _oneDriveController.rootFolder.name;
+        } else {
             _oneDriveController.currentFolder = _oneDriveController.currentFolder.parent;
+            self.title = _oneDriveController.currentFolder.name;
+        }
         [_activityIndicator startAnimating];
         [_oneDriveController loadCurrentFolder];
     } else
@@ -134,6 +137,7 @@
         [_activityIndicator startAnimating];
         _oneDriveController.currentFolder = selectedObject;
         [_oneDriveController loadCurrentFolder];
+        self.title = selectedObject.name;
     } else {
         /* stream file */
         NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];