]> git.sesse.net Git - vlc/commitdiff
macosx/framework: Only fetch meta when needed.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 16 Feb 2008 00:33:48 +0000 (00:33 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 16 Feb 2008 00:33:48 +0000 (00:33 +0000)
projects/macosx/framework/Headers/Public/VLCMedia.h
projects/macosx/framework/Sources/VLCMedia.m

index 58d07047c65c8abdecb2cab2860d8a5ca14b5699..75b3fde4d21eb5d5595e32902b47c5d6bee00a90 100644 (file)
@@ -113,7 +113,7 @@ typedef enum VLCMediaState
     VLCTime *             length;            //< Duration of the media
     NSMutableDictionary * metaDictionary;    //< Meta data storage
     id                    delegate;          //< Delegate object
-    BOOL                  preparsed;         //< Value used to determine of the file has been preparsed
+    BOOL                  artFetched;        //< Value used to determine of the artwork has been preparsed
     VLCMediaState         state;
 }
 
index 2509d2e2f838553dc73525c1ceb8e108857c8edd..5e96e23d422bde2051c82b504244e07fe600e8db 100644 (file)
@@ -430,6 +430,8 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
     libvlc_exception_t ex;
     libvlc_exception_init( &ex );
 
+    artFetched = NO;
+
     char * p_url = libvlc_media_descriptor_get_mrl( p_md, &ex );
     catch_exception( &ex );
 
@@ -463,9 +465,6 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
     /* Force VLCMetaInformationTitle, that will trigger preparsing
      * And all the other meta will be added through the libvlc event system */
     [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
-
-    /* Force VLCMetaInformationArtworkURL, that will trigger artwork fetching */
-    [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationArtworkURL];
 }
 
 - (void)fetchMetaInformationFromLibVLCWithType:(NSString *)metaType
@@ -545,6 +544,17 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
 {
     [self setState: [newStateAsNumber intValue]];
 }
+
+- (id)valueForKeyPath:(NSString *)keyPath
+{
+    if( ![metaDictionary objectForKey:@"artwork"] && [keyPath isEqualToString:@"metaDictionary.artwork"])
+    {
+        artFetched = YES;
+        /* Force the retrieval of the artwork now that someone asked for it */
+        [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationArtworkURL];
+    }
+    return [super valueForKeyPath:keyPath];
+}
 @end
 
 /******************************************************************************