소스 검색

Fix UPNP media files are listed with 0 bytes in size, by calculation (bitrate * duration) if size is null

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 11 년 전
부모
커밋
23b9f70a1e
1개의 변경된 파일17개의 추가작업 그리고 1개의 파일을 삭제
  1. 17 1
      Sources/VLCLocalServerFolderListViewController.m

+ 17 - 1
Sources/VLCLocalServerFolderListViewController.m

@@ -185,12 +185,28 @@
 
         if (![item isContainer]) {
             MediaServer1ItemObject *mediaItem;
+            NSInteger mediaSize = 0;
+
             if (tableView == self.searchDisplayController.searchResultsTableView)
                 mediaItem = _searchData[indexPath.row];
             else
                 mediaItem = _mutableObjectList[indexPath.row];
 
-            [cell setSubtitle: [NSString stringWithFormat:@"%0.2f MB  (%@)", (float)([mediaItem.size intValue] / 1e6), mediaItem.duration]];
+            if (![mediaItem size]) {
+                NSRange end = [mediaItem.duration rangeOfString:@"."];
+                NSString *timeString =[mediaItem.duration substringWithRange:NSMakeRange(0, end.location)];
+
+                NSArray *arrayTime = [timeString componentsSeparatedByString:@":"];
+                NSInteger hours   = [[arrayTime objectAtIndex:0] integerValue];
+                NSInteger minutes = [[arrayTime objectAtIndex:1] integerValue];
+                NSInteger seconds = [[arrayTime objectAtIndex:2] integerValue];
+
+                mediaSize = [mediaItem.bitrate integerValue] * ((hours * 60 * 60) + (minutes * 60) + seconds);
+            }
+            else
+                mediaSize = [mediaItem.size integerValue];
+
+            [cell setSubtitle: [NSString stringWithFormat:@"%0.2f MB  (%@)", (float)(mediaSize / 1e6), mediaItem.duration]];
             [cell setIsDirectory:NO];
             cell.isDownloadable = YES;
             if (![mediaItem.albumArt isEqualToString:NULL]) {