[vlc-commits] macosx/library: allow creating items using URLs

Felix Paul Kühne git at videolan.org
Mon Jul 8 21:38:07 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Jul  8 20:35:08 2019 +0200| [c865407a296c47ac465d7ba934b1fca500c837aa] | committer: Felix Paul Kühne

macosx/library: allow creating items using URLs

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c865407a296c47ac465d7ba934b1fca500c837aa
---

 modules/gui/macosx/library/VLCLibraryDataTypes.h |  2 ++
 modules/gui/macosx/library/VLCLibraryDataTypes.m | 32 ++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index d81be57384..2fcbb09b0e 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -149,6 +149,8 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 + (nullable instancetype)mediaItemForLibraryID:(int64_t)libraryID;
 - (instancetype)initWithMediaItem:(struct vlc_ml_media_t *)mediaItem;
+- (instancetype)initWithExternalURL:(NSURL *)url;
+- (instancetype)initWithStreamURL:(NSURL *)url;
 
 @property (readonly) int64_t libraryID;
 @property (readonly) vlc_ml_media_type_t mediaType;
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index eb56aca49a..30b7863658 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -302,6 +302,38 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     return self;
 }
 
+- (instancetype)initWithExternalURL:(NSURL *)url
+{
+    NSString *urlString = url.absoluteString;
+    if (!urlString) {
+        return self;
+    }
+
+    vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(getIntf());
+    vlc_ml_media_t *p_media = vlc_ml_new_external_media(p_mediaLibrary, urlString.UTF8String);
+    if (p_media) {
+        self = [self initWithMediaItem:p_media library:p_mediaLibrary];
+        vlc_ml_media_release(p_media);
+    }
+    return self;
+}
+
+- (instancetype)initWithStreamURL:(NSURL *)url
+{
+    NSString *urlString = url.absoluteString;
+    if (!urlString) {
+        return self;
+    }
+
+    vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(getIntf());
+    vlc_ml_media_t *p_media = vlc_ml_new_stream(p_mediaLibrary, urlString.UTF8String);
+    if (p_media) {
+        self = [self initWithMediaItem:p_media library:p_mediaLibrary];
+        vlc_ml_media_release(p_media);
+    }
+    return self;
+}
+
 - (instancetype)initWithCoder:(NSCoder *)aDecoder
 {
     int64_t libraryID = [aDecoder decodeInt64ForKey:VLCMediaLibraryMediaItemLibraryID];



More information about the vlc-commits mailing list