[vlc-devel] commit: macosx/framework: Only create the NSImage corresponding to the artwork if asked. (Pierre d' Herbemont )
git version control
git at videolan.org
Wed Jan 6 16:28:57 CET 2010
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Tue Jan 5 18:44:29 2010 +0100| [81dc52be2f20ad0aee3835a66a84075c796e9d89] | committer: Pierre d'Herbemont
macosx/framework: Only create the NSImage corresponding to the artwork if asked.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=81dc52be2f20ad0aee3835a66a84075c796e9d89
---
.../macosx/framework/Headers/Public/VLCMedia.h | 1 +
projects/macosx/framework/Sources/VLCMedia.m | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/projects/macosx/framework/Headers/Public/VLCMedia.h b/projects/macosx/framework/Headers/Public/VLCMedia.h
index 84d778f..69e3d08 100644
--- a/projects/macosx/framework/Headers/Public/VLCMedia.h
+++ b/projects/macosx/framework/Headers/Public/VLCMedia.h
@@ -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
}
diff --git a/projects/macosx/framework/Sources/VLCMedia.m b/projects/macosx/framework/Sources/VLCMedia.m
index 7a1bd77..54bca01 100644
--- a/projects/macosx/framework/Sources/VLCMedia.m
+++ b/projects/macosx/framework/Sources/VLCMedia.m
@@ -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
More information about the vlc-devel
mailing list