[vlc-commits] macosx: expoxe media library item for playlist item
Felix Paul Kühne
git at videolan.org
Mon Jul 15 13:58:28 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jul 14 17:27:40 2019 +0200| [7164ea0c5c4cee84d645310b9cfd1565e0f1e497] | committer: Felix Paul Kühne
macosx: expoxe media library item for playlist item
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7164ea0c5c4cee84d645310b9cfd1565e0f1e497
---
modules/gui/macosx/library/VLCLibraryDataTypes.h | 1 +
modules/gui/macosx/library/VLCLibraryDataTypes.m | 14 +++++++++++++-
modules/gui/macosx/playlist/VLCPlaylistItem.h | 2 ++
modules/gui/macosx/playlist/VLCPlaylistItem.m | 6 ++++++
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index 2fcbb09b0e..b9149a7a3a 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -148,6 +148,7 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
@interface VLCMediaLibraryMediaItem : NSObject
+ (nullable instancetype)mediaItemForLibraryID:(int64_t)libraryID;
++ (nullable instancetype)mediaItemForURL:(NSURL *)url;
- (instancetype)initWithMediaItem:(struct vlc_ml_media_t *)mediaItem;
- (instancetype)initWithExternalURL:(NSURL *)url;
- (instancetype)initWithStreamURL:(NSURL *)url;
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index 30b7863658..4329e09c43 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -232,7 +232,19 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
+ (nullable instancetype)mediaItemForLibraryID:(int64_t)libraryID
{
vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(getIntf());
- vlc_ml_media_t *p_mediaItem = vlc_ml_get(p_mediaLibrary, VLC_ML_GET_MEDIA, libraryID);
+ vlc_ml_media_t *p_mediaItem = vlc_ml_get_media(p_mediaLibrary, libraryID);
+ VLCMediaLibraryMediaItem *returnValue = nil;
+ if (p_mediaItem) {
+ returnValue = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:p_mediaItem library:p_mediaLibrary];
+ }
+ return returnValue;
+}
+
++ (instancetype)mediaItemForURL:(NSURL *)url
+{
+ vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(getIntf());
+ vlc_ml_media_t *p_mediaItem = vlc_ml_get_media_by_mrl(p_mediaLibrary,
+ [[url absoluteString] UTF8String]);
VLCMediaLibraryMediaItem *returnValue = nil;
if (p_mediaItem) {
returnValue = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:p_mediaItem library:p_mediaLibrary];
diff --git a/modules/gui/macosx/playlist/VLCPlaylistItem.h b/modules/gui/macosx/playlist/VLCPlaylistItem.h
index a7cc2b524b..a8841f1acc 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistItem.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistItem.h
@@ -26,6 +26,7 @@
NS_ASSUME_NONNULL_BEGIN
@class VLCInputItem;
+ at class VLCMediaLibraryMediaItem;
@interface VLCPlaylistItem : NSObject
@@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly, copy, nullable) NSString *path;
@property (readwrite, assign) vlc_tick_t duration;
@property (readonly, nullable) VLCInputItem *inputItem;
+ at property (readonly, nullable) VLCMediaLibraryMediaItem *mediaLibraryItem;
@property (readwrite, retain, nullable) NSString *artistName;
@property (readwrite, retain, nullable) NSString *albumName;
diff --git a/modules/gui/macosx/playlist/VLCPlaylistItem.m b/modules/gui/macosx/playlist/VLCPlaylistItem.m
index be6a18450e..f6792903ef 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistItem.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistItem.m
@@ -27,6 +27,7 @@
#import "extensions/NSString+Helpers.h"
#import "library/VLCInputItem.h"
+#import "library/VLCLibraryDataTypes.h"
@implementation VLCPlaylistItem
@@ -64,6 +65,11 @@
return inputItem;
}
+- (VLCMediaLibraryMediaItem *)mediaLibraryItem
+{
+ return [VLCMediaLibraryMediaItem mediaItemForURL:self.url];
+}
+
- (void)updateRepresentation
{
input_item_t *p_media = vlc_playlist_item_GetMedia(_playlistItem);
More information about the vlc-commits
mailing list