Browse Source

add thumbnailURL to ServerBrowserItem-Protocol
download thumbnail in ServerBrowserViewController

Tobias Conradi 9 years ago
parent
commit
7d66951dd2

+ 1 - 1
Sources/LocalNetworkConnectivity/ServerBrowsing/VLCNetworkServerBrowser-Protocol.h

@@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
 @optional
 @property (nonatomic, readonly, nullable) NSString *duration;
 @property (nonatomic, readonly, nullable) NSURL *subtitleURL;
-
+@property (nonatomic, readonly, nullable) NSURL *thumbnailURL;
 @end
 
 

+ 1 - 0
Sources/LocalNetworkConnectivity/ServerBrowsing/VLCNetworkServerBrowserSharedLibrary.h

@@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
 - (instancetype)initWithDictionary:(NSDictionary *)dictionary;
 @property (nonatomic, readonly, nullable) NSURL *subtitleURL;
 @property (nonatomic, readonly, nullable) NSString *duration;
+@property (nonatomic, readonly, nullable) NSURL *thumbnailURL;
 
 @end
 

+ 5 - 3
Sources/LocalNetworkConnectivity/ServerBrowsing/VLCNetworkServerBrowserSharedLibrary.m

@@ -70,16 +70,18 @@
     self = [super init];
     if (self) {
         _name = dictionary[@"title"];
-        NSString *thumbURLString = dictionary[@"thumb"];
-        _subtitleURL = thumbURLString ? [NSURL URLWithString:thumbURLString] : nil;
         _fileSizeBytes = dictionary[@"size"];
         _duration = dictionary[@"duration"];
         NSString *subtitleURLString = dictionary[@"pathSubtitle"];
         if ([subtitleURLString isEqualToString:@"(null)"]) subtitleURLString = nil;
         subtitleURLString = [subtitleURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-        _subtitleURL = subtitleURLString ? [NSURL URLWithString:subtitleURLString] : nil;
+        _subtitleURL = subtitleURLString.length ? [NSURL URLWithString:subtitleURLString] : nil;
         _URL = [NSURL URLWithString:dictionary[@"pathfile"]];
         _container = NO;
+
+        NSString *thumbURLString = dictionary[@"thumb"];
+        _thumbnailURL = thumbURLString.length ? [NSURL URLWithString:thumbURLString] : nil;
+
     }
     return self;
 }

+ 4 - 0
Sources/LocalNetworkConnectivity/ServerBrowsing/VLCNetworkServerBrowserViewController.m

@@ -244,6 +244,10 @@
         cell.delegate = self;
 
         NSURL *thumbnailURL = nil;
+        if ([item respondsToSelector:@selector(thumbnailURL)]) {
+            thumbnailURL = item.thumbnailURL;
+        }
+        
         if (thumbnailURL) {
             dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
             dispatch_async(queue, ^{