]> git.sesse.net Git - vlc/commitdiff
macosx/framework: Only create the NSImage corresponding to the artwork if asked.
authorPierre d'Herbemont <pdherbemont@free.fr>
Tue, 5 Jan 2010 17:44:29 +0000 (18:44 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Wed, 6 Jan 2010 15:28:54 +0000 (16:28 +0100)
projects/macosx/framework/Headers/Public/VLCMedia.h
projects/macosx/framework/Sources/VLCMedia.m

index 84d778f8b36ebafb048fa6970e64dbe3fe389c2a..69e3d083aec27cc36188464b6227b8a71fcb6f87 100644 (file)
@@ -114,6 +114,7 @@ typedef enum VLCMediaState
     id                    delegate;          //< Delegate object
     BOOL                  isArtFetched;      //< Value used to determine of the artwork has been preparsed
     BOOL                  areOthersMetaFetched; //< Value used to determine of the other meta has been preparsed
+    BOOL                  isArtURLFetched;   //< Value used to determine of the other meta has been preparsed
     VLCMediaState         state;             //< Current state of the media
 }
 
index 7a1bd7776d233c128fc8831c30a4921e941ef248..54bca01124133ac5547452bb7f5ab813947d18f7 100644 (file)
@@ -466,12 +466,12 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
 
     if ( newValue != oldValue && !(oldValue && newValue && [oldValue compare:newValue] == NSOrderedSame) )
     {
-        if ([metaType isEqualToString:VLCMetaInformationArtworkURL])
+        // Only fetch the art if needed. (ie, create the NSImage, if it was requested before)
+        if (isArtFetched && [metaType isEqualToString:VLCMetaInformationArtworkURL])
         {
             [NSThread detachNewThreadSelector:@selector(fetchMetaInformationForArtWorkWithURL:) 
                                          toTarget:self
                                        withObject:newValue];
-            return;
         }
 
         [metaDictionary setValue:newValue forKeyPath:metaType];
@@ -550,7 +550,14 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
          * And all the other meta will be added through the libvlc event system */
         [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
     }
-
+    else if( !isArtURLFetched && [keyPath hasPrefix:@"metaDictionary.artworkURL"])
+    {
+        isArtURLFetched = YES;
+        /* Force isArtURLFetched, that will trigger artwork download eventually
+         * And all the other meta will be added through the libvlc event system */
+        [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationArtworkURL];
+    }
+    
     return [super valueForKeyPath:keyPath];
 }
 @end