[vlc-commits] macosx/library: add abstractions for albums, artists and genres

Felix Paul Kühne git at videolan.org
Mon May 13 13:24:26 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed May  8 12:10:33 2019 +0200| [cf70f1370260eb4847f27dda1477c5b6cda95251] | committer: Felix Paul Kühne

macosx/library: add abstractions for albums, artists and genres

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

 modules/gui/macosx/library/VLCLibraryDataTypes.h | 40 +++++++++++++++++
 modules/gui/macosx/library/VLCLibraryDataTypes.m | 55 ++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index 67a8fac729..eb7bdba8a8 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -79,6 +79,36 @@ NS_ASSUME_NONNULL_BEGIN
 
 @end
 
+ at interface VLCMediaLibraryArtist : NSObject
+
+- (instancetype)initWithArtist:(struct vlc_ml_artist_t *)p_artist;
+
+ at property (readonly) int64_t artistID;
+ at property (readonly) NSString *name;
+ at property (readonly) NSString *shortBiography;
+ at property (readonly) NSString *artworkMRL;
+ at property (readonly) NSString *musicBrainzID;
+ at property (readonly) unsigned int numberOfAlbums;
+ at property (readonly) unsigned int numberOfTracks;
+
+ at end
+
+ at interface VLCMediaLibraryAlbum : NSObject
+
+- (instancetype)initWithAlbum:(struct vlc_ml_album_t *)p_album;
+
+ at property (readonly) int64_t albumID;
+ at property (readonly) NSString *title;
+ at property (readonly) NSString *summary;
+ at property (readonly) NSString *artworkMRL;
+ at property (readonly) NSString *artistName;
+ at property (readonly) int64_t artistID;
+ at property (readonly) size_t numberOfTracks;
+ at property (readonly) unsigned int duration;
+ at property (readonly) unsigned int year;
+
+ at end
+
 @interface VLCMediaLibraryAlbumTrack : NSObject
 
 - (instancetype)initWithAlbumTrack:(struct vlc_ml_album_track_t *)p_albumTrack;
@@ -92,6 +122,16 @@ NS_ASSUME_NONNULL_BEGIN
 
 @end
 
+ at interface VLCMediaLibraryGenre : NSObject
+
+- (instancetype)initWithGenre:(struct vlc_ml_genre_t *)p_genre;
+
+ at property (readonly) int64_t genreID;
+ at property (readonly) NSString *name;
+ at property (readonly) size_t numberOfTracks;
+
+ at end
+
 @interface VLCMediaLibraryMediaItem : NSObject
 
 + (nullable instancetype)mediaItemForLibraryID:(int64_t)libraryID;
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index 228b99076a..e3211672a6 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -111,6 +111,46 @@
 
 @end
 
+ at implementation VLCMediaLibraryArtist
+
+- (instancetype)initWithArtist:(struct vlc_ml_artist_t *)p_artist;
+{
+    self = [super init];
+    if (self && p_artist != NULL) {
+        _artistID = p_artist->i_id;
+        _name = toNSStr(p_artist->psz_name);
+        _shortBiography = toNSStr(p_artist->psz_shortbio);
+        _artworkMRL = toNSStr(p_artist->psz_artwork_mrl);
+        _musicBrainzID = toNSStr(p_artist->psz_mb_id);
+        _numberOfAlbums = p_artist->i_nb_album;
+        _numberOfTracks = p_artist->i_nb_tracks;
+    }
+    return self;
+}
+
+ at end
+
+ at implementation VLCMediaLibraryAlbum
+
+- (instancetype)initWithAlbum:(struct vlc_ml_album_t *)p_album
+{
+    self = [super init];
+    if (self && p_album != NULL) {
+        _albumID = p_album->i_id;
+        _title = toNSStr(p_album->psz_title);
+        _summary = toNSStr(p_album->psz_summary);
+        _artworkMRL = toNSStr(p_album->psz_artwork_mrl);
+        _artistName = toNSStr(p_album->psz_artist);
+        _artistID = p_album->i_artist_id;
+        _numberOfTracks = p_album->i_nb_tracks;
+        _duration = p_album->i_duration;
+        _year = p_album->i_year;
+    }
+    return self;
+}
+
+ at end
+
 @implementation VLCMediaLibraryAlbumTrack
 
 - (instancetype)initWithAlbumTrack:(struct vlc_ml_album_track_t *)p_albumTrack
@@ -129,6 +169,21 @@
 
 @end
 
+ at implementation VLCMediaLibraryGenre
+
+- (instancetype)initWithGenre:(struct vlc_ml_genre_t *)p_genre
+{
+    self = [super init];
+    if (self && p_genre != NULL) {
+        _genreID = p_genre->i_id;
+        _name = toNSStr(p_genre->psz_name);
+        _numberOfTracks = p_genre->i_nb_tracks;
+    }
+    return self;
+}
+
+ at end
+
 @interface VLCMediaLibraryMediaItem ()
 
 @property (readwrite, assign) vlc_medialibrary_t *p_mediaLibrary;



More information about the vlc-commits mailing list