[vlc-commits] macosx/media source: show artwork if provided
Felix Paul Kühne
git at videolan.org
Sun Jun 30 14:22:43 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jun 30 14:20:55 2019 +0200| [67ea7e407429c7301e05adbac323cbd4b9da7432] | committer: Felix Paul Kühne
macosx/media source: show artwork if provided
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=67ea7e407429c7301e05adbac323cbd4b9da7432
---
modules/gui/macosx/library/VLCInputItem.h | 1 +
modules/gui/macosx/library/VLCInputItem.m | 13 +++++++++++++
.../gui/macosx/media-source/VLCMediaSourceBaseDataSource.m | 8 ++++++++
.../macosx/media-source/VLCMediaSourceCollectionViewItem.m | 8 ++++----
modules/gui/macosx/media-source/VLCMediaSourceDataSource.m | 10 ++++++++++
5 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/modules/gui/macosx/library/VLCInputItem.h b/modules/gui/macosx/library/VLCInputItem.h
index a9e9690a9d..5b5f1d221c 100644
--- a/modules/gui/macosx/library/VLCInputItem.h
+++ b/modules/gui/macosx/library/VLCInputItem.h
@@ -42,6 +42,7 @@ extern NSString *VLCInputItemSubtreeAdded;
@property (readonly) vlc_tick_t duration;
@property (readonly) enum input_item_type_e inputType;
@property (readonly) struct input_item_node_t *subTree;
+ at property (readonly) NSURL *artworkURL;
- (void)parseInputItem;
- (void)cancelParsing;
diff --git a/modules/gui/macosx/library/VLCInputItem.m b/modules/gui/macosx/library/VLCInputItem.m
index 394114cef4..16e512cf70 100644
--- a/modules/gui/macosx/library/VLCInputItem.m
+++ b/modules/gui/macosx/library/VLCInputItem.m
@@ -115,6 +115,19 @@ static const struct input_item_parser_cbs_t parserCallbacks =
return ITEM_TYPE_UNKNOWN;
}
+- (NSURL *)artworkURL
+{
+ if (_vlcInputItem) {
+ char *p_artworkURL = input_item_GetArtworkURL(_vlcInputItem);
+ if (p_artworkURL) {
+ NSString *artworkURLString = toNSStr(p_artworkURL);
+ FREENULL(p_artworkURL);
+ return [NSURL URLWithString:artworkURLString];
+ }
+ }
+ return nil;
+}
+
- (void)parseInputItem
{
_p_parserID = input_item_Parse(_vlcInputItem,
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
index 3f5ecdc433..885d266268 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
@@ -119,6 +119,14 @@
VLCInputItem *childRootInput = childNode.inputItem;
viewItem.titleTextField.stringValue = childRootInput.name;
+ NSURL *artworkURL = childRootInput.artworkURL;
+ NSImage *placeholder = [NSImage imageNamed:@"NSApplicationIcon"];
+ if (artworkURL) {
+ [viewItem.mediaImageView setImageURL:artworkURL placeholderImage:placeholder];
+ } else {
+ viewItem.mediaImageView.image = placeholder;
+ }
+
return viewItem;
}
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
index 29b7b9b71a..708fffb55e 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceCollectionViewItem.m
@@ -31,10 +31,10 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCMediaSourceCellIdentifier";
@implementation VLCMediaSourceCollectionViewItem
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- [self.mediaImageView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
+- (void)prepareForReuse
+{
+ [super prepareForReuse];
+ self.mediaImageView.image = nil;
}
@end
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
index 329f7977fe..475efd47df 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
@@ -27,6 +27,8 @@
#import "media-source/VLCMediaSource.h"
#import "main/VLCMain.h"
#import "playlist/VLCPlaylistController.h"
+#import "views/VLCImageView.h"
+#import "extensions/NSString+Helpers.h"
@interface VLCMediaSourceDataSource()
{
@@ -71,6 +73,14 @@
VLCInputItem *childRootInput = childNode.inputItem;
viewItem.titleTextField.stringValue = childRootInput.name;
+ NSURL *artworkURL = childRootInput.artworkURL;
+ NSImage *placeholder = [NSImage imageNamed:@"NSApplicationIcon"];
+ if (artworkURL) {
+ [viewItem.mediaImageView setImageURL:artworkURL placeholderImage:placeholder];
+ } else {
+ viewItem.mediaImageView.image = placeholder;
+ }
+
return viewItem;
}
More information about the vlc-commits
mailing list