[vlc-commits] [Git][videolan/vlc][master] macosx: Make the Information Panel compatible with more media library item types

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sat Jul 30 09:40:50 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
340dd812 by Claudio Cambra at 2022-07-30T09:20:16+00:00
macosx: Make the Information Panel compatible with more media library item types

Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>

- - - - -


7 changed files:

- modules/gui/macosx/UI/VLCLibraryInformationPanel.xib
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/VLCLibraryInformationPanel.h
- modules/gui/macosx/library/VLCLibraryInformationPanel.m
- modules/gui/macosx/library/VLCLibraryMenuController.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryInformationPanel.xib
=====================================
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryInformationPanel">
             <connections>
                 <outlet property="imageView" destination="N4h-LP-IRY" id="Ned-Ju-hyu"/>
-                <outlet property="multiLineTextLabel" destination="OhC-hA-R2H" id="Q6T-Ol-Gdc"/>
+                <outlet property="textView" destination="BG5-o2-dKa" id="Q6T-Ol-Gdc"/>
                 <outlet property="window" destination="oPi-wT-0nK" id="ODs-Hv-85I"/>
             </connections>
         </customObject>
@@ -17,36 +17,63 @@
         <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="" animationBehavior="default" id="oPi-wT-0nK" customClass="NSPanel">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" utility="YES" HUD="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="136" y="189" width="595" height="512"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
+            <rect key="contentRect" x="136" y="189" width="512" height="640"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <value key="minSize" type="size" width="386" height="227"/>
-            <view key="contentView" misplaced="YES" id="Nfs-rF-cUN">
-                <rect key="frame" x="0.0" y="0.0" width="595" height="403"/>
+            <view key="contentView" id="Nfs-rF-cUN">
+                <rect key="frame" x="0.0" y="0.0" width="512" height="640"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="N4h-LP-IRY">
-                        <rect key="frame" x="20" y="20" width="555" height="347"/>
+                        <rect key="frame" x="20" y="20" width="472" height="295"/>
                         <constraints>
                             <constraint firstAttribute="width" secondItem="N4h-LP-IRY" secondAttribute="height" multiplier="16:10" id="bqe-XE-yWC"/>
                         </constraints>
                         <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="8o3-U6-XgQ"/>
                     </imageView>
-                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="OhC-hA-R2H">
-                        <rect key="frame" x="18" y="367" width="559" height="16"/>
-                        <textFieldCell key="cell" selectable="YES" title="Multiline Label" id="caT-3r-bkd">
-                            <font key="font" metaFont="system"/>
-                            <color key="textColor" name="selectedMenuItemTextColor" catalog="System" colorSpace="catalog"/>
-                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                        </textFieldCell>
-                    </textField>
+                    <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qS0-eY-moI">
+                        <rect key="frame" x="20" y="335" width="472" height="285"/>
+                        <clipView key="contentView" drawsBackground="NO" id="a0y-wC-gCb">
+                            <rect key="frame" x="0.0" y="0.0" width="457" height="285"/>
+                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            <subviews>
+                                <textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="BG5-o2-dKa">
+                                    <rect key="frame" x="0.0" y="0.0" width="457" height="285"/>
+                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                    <color key="textColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" red="0.89527153969999995" green="0.9043967128" blue="0.92996197940000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <size key="minSize" width="457" height="285"/>
+                                    <size key="maxSize" width="555" height="10000000"/>
+                                    <attributedString key="textStorage">
+                                        <fragment content="Media info">
+                                            <attributes>
+                                                <color key="NSColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                <font key="NSFont" metaFont="system"/>
+                                                <paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
+                                            </attributes>
+                                        </fragment>
+                                    </attributedString>
+                                    <color key="insertionPointColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textView>
+                            </subviews>
+                        </clipView>
+                        <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="zeg-Td-OE6">
+                            <rect key="frame" x="-100" y="-100" width="225" height="15"/>
+                            <autoresizingMask key="autoresizingMask"/>
+                        </scroller>
+                        <scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="b3U-Br-b1q">
+                            <rect key="frame" x="457" y="0.0" width="15" height="285"/>
+                            <autoresizingMask key="autoresizingMask"/>
+                        </scroller>
+                    </scrollView>
                 </subviews>
                 <constraints>
-                    <constraint firstItem="OhC-hA-R2H" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" constant="20" id="BVL-Xu-cDU"/>
+                    <constraint firstAttribute="trailing" secondItem="qS0-eY-moI" secondAttribute="trailing" constant="20" id="5zW-yH-q6o"/>
+                    <constraint firstItem="qS0-eY-moI" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" constant="20" id="XAb-wK-mSu"/>
                     <constraint firstAttribute="trailing" secondItem="N4h-LP-IRY" secondAttribute="trailing" constant="20" id="cEY-J9-usm"/>
                     <constraint firstItem="N4h-LP-IRY" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" constant="20" id="kKf-aB-0vG"/>
-                    <constraint firstItem="N4h-LP-IRY" firstAttribute="top" secondItem="OhC-hA-R2H" secondAttribute="bottom" id="mhR-pO-oDr"/>
-                    <constraint firstItem="OhC-hA-R2H" firstAttribute="top" secondItem="Nfs-rF-cUN" secondAttribute="top" constant="20" id="ugM-Yv-u0C"/>
-                    <constraint firstAttribute="trailing" secondItem="OhC-hA-R2H" secondAttribute="trailing" constant="20" id="yEE-lN-RaR"/>
+                    <constraint firstItem="qS0-eY-moI" firstAttribute="bottom" secondItem="N4h-LP-IRY" secondAttribute="top" constant="-20" id="mH4-ni-caL"/>
+                    <constraint firstItem="qS0-eY-moI" firstAttribute="top" secondItem="Nfs-rF-cUN" secondAttribute="top" constant="20" id="p0Y-Nb-dxf"/>
                     <constraint firstAttribute="bottom" secondItem="N4h-LP-IRY" secondAttribute="bottom" constant="20" id="zc5-8x-CjC"/>
                 </constraints>
             </view>


=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -269,7 +269,7 @@
         case VLC_ML_PARENT_ARTIST:
         {
             VLCMediaLibraryArtist *artist = _displayedCollection[self.collectionSelectionTableView.selectedRow];
-            NSArray *albumsForArtist = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_ARTIST forID:artist.artistID];
+            NSArray *albumsForArtist = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_ARTIST forID:artist.libraryID];
             _groupDataSource.representedListOfAlbums = albumsForArtist;
             break;
         }
@@ -288,7 +288,7 @@
         case VLC_ML_PARENT_GENRE:
         {
             VLCMediaLibraryGenre *genre = _displayedCollection[self.collectionSelectionTableView.selectedRow];
-            NSArray *albumsForGenre = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_GENRE forID:genre.genreID];
+            NSArray *albumsForGenre = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_GENRE forID:genre.libraryID];
             _groupDataSource.representedListOfAlbums = albumsForGenre;
             break;
         }
@@ -329,7 +329,7 @@
         case VLC_ML_PARENT_ARTIST:
         {
             VLCMediaLibraryArtist *artist = _displayedCollection[self.collectionSelectionTableView.selectedRow];
-            listOfAlbums = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_ARTIST forID:artist.artistID];
+            listOfAlbums = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_ARTIST forID:artist.libraryID];
             break;
         }
         case VLC_ML_PARENT_ALBUM:
@@ -347,7 +347,7 @@
         case VLC_ML_PARENT_GENRE:
         {
             VLCMediaLibraryGenre *genre = _displayedCollection[self.collectionSelectionTableView.selectedRow];
-            listOfAlbums = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_GENRE forID:genre.genreID];
+            listOfAlbums = [_libraryModel listAlbumsOfParentType:VLC_ML_PARENT_GENRE forID:genre.libraryID];
             break;
         }
         default:


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -99,6 +99,7 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 @protocol VLCMediaLibraryItemProtocol <NSObject>
 
+ at property (readonly) int64_t libraryID;
 @property (readonly) BOOL smallArtworkGenerated;
 @property (readonly) NSImage *smallArtworkImage;
 @property (readonly) NSString *smallArtworkMRL;
@@ -115,7 +116,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 + (nullable instancetype)artistWithID:(int64_t)artistID;
 - (instancetype)initWithArtist:(struct vlc_ml_artist_t *)p_artist;
 
- at property (readonly) int64_t artistID;
 @property (readonly) NSString *name;
 @property (readonly) NSString *shortBiography;
 @property (readonly) NSString *musicBrainzID;
@@ -130,7 +130,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 - (instancetype)initWithAlbum:(struct vlc_ml_album_t *)p_album;
 
- at property (readonly) int64_t albumID;
 @property (readonly) NSString *title;
 @property (readonly) NSString *summary;
 @property (readonly) NSString *artistName;
@@ -146,7 +145,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 - (instancetype)initWithGenre:(struct vlc_ml_genre_t *)p_genre;
 
- at property (readonly) int64_t genreID;
 @property (readonly) NSString *name;
 @property (readonly) size_t numberOfTracks;
 @property (readonly) NSArray <VLCMediaLibraryArtist *> *artists;
@@ -165,7 +163,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 - (nullable instancetype)initWithExternalURL:(NSURL *)url;
 - (nullable instancetype)initWithStreamURL:(NSURL *)url;
 
- at property (readonly) int64_t libraryID;
 @property (readonly) vlc_ml_media_type_t mediaType;
 @property (readonly) NSString *readableMediaType;
 @property (readonly) vlc_ml_media_subtype_t mediaSubType;


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -182,6 +182,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 
 @implementation VLCMediaLibraryArtist
 
+ at synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
 
@@ -207,7 +208,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 {
     self = [super init];
     if (self && p_artist != NULL) {
-        _artistID = p_artist->i_id;
+        _libraryID = p_artist->i_id;
         _name = toNSStr(p_artist->psz_name);
         _shortBiography = toNSStr(p_artist->psz_shortbio);
         _smallArtworkGenerated = p_artist->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl != NULL;
@@ -260,7 +261,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_album_list_t *p_albumList = vlc_ml_list_artist_albums(p_mediaLibrary, NULL, _artistID);
+    vlc_ml_album_list_t *p_albumList = vlc_ml_list_artist_albums(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_albumList->i_nb_items];
     for (size_t x = 0; x < p_albumList->i_nb_items; x++) {
         VLCMediaLibraryAlbum *album = [[VLCMediaLibraryAlbum alloc] initWithAlbum:&p_albumList->p_items[x]];
@@ -280,7 +281,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_artist_tracks(p_mediaLibrary, NULL, _artistID);
+    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_artist_tracks(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_mediaList->i_nb_items];
     for (size_t x = 0; x < p_mediaList->i_nb_items; x++) {
         VLCMediaLibraryMediaItem *mediaItem = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:&p_mediaList->p_items[x]];
@@ -306,6 +307,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 
 @implementation VLCMediaLibraryAlbum
 
+ at synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
 
@@ -313,7 +315,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 {
     self = [super init];
     if (self && p_album != NULL) {
-        _albumID = p_album->i_id;
+        _libraryID = p_album->i_id;
         _title = toNSStr(p_album->psz_title);
         _summary = toNSStr(p_album->psz_summary);
         _smallArtworkGenerated = p_album->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl != NULL;
@@ -357,7 +359,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_album_tracks(p_mediaLibrary, NULL, _albumID);
+    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_album_tracks(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_mediaList->i_nb_items];
     for (size_t x = 0; x < p_mediaList->i_nb_items; x++) {
         VLCMediaLibraryMediaItem *mediaItem = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:&p_mediaList->p_items[x]];
@@ -383,6 +385,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 
 @implementation VLCMediaLibraryGenre
 
+ at synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
 
@@ -390,7 +393,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 {
     self = [super init];
     if (self && p_genre != NULL) {
-        _genreID = p_genre->i_id;
+        _libraryID = p_genre->i_id;
         _name = toNSStr(p_genre->psz_name);
         _numberOfTracks = p_genre->i_nb_tracks;
         _smallArtworkGenerated = p_genre->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl != NULL;
@@ -432,7 +435,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_album_list_t *p_albumList = vlc_ml_list_genre_albums(p_mediaLibrary, NULL, _genreID);
+    vlc_ml_album_list_t *p_albumList = vlc_ml_list_genre_albums(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_albumList->i_nb_items];
     for (size_t x = 0; x < p_albumList->i_nb_items; x++) {
         VLCMediaLibraryAlbum *album = [[VLCMediaLibraryAlbum alloc] initWithAlbum:&p_albumList->p_items[x]];
@@ -452,7 +455,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_artist_list_t *p_artistList = vlc_ml_list_genre_artists(p_mediaLibrary, NULL, _genreID);
+    vlc_ml_artist_list_t *p_artistList = vlc_ml_list_genre_artists(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_artistList->i_nb_items];
     for (size_t x = 0; x < p_artistList->i_nb_items; x++) {
         VLCMediaLibraryArtist *artist = [[VLCMediaLibraryArtist alloc] initWithArtist:&p_artistList->p_items[x]];
@@ -472,7 +475,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
     if (!p_mediaLibrary) {
         return @[];
     }
-    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_genre_tracks(p_mediaLibrary, NULL, _genreID);
+    vlc_ml_media_list_t *p_mediaList = vlc_ml_list_genre_tracks(p_mediaLibrary, NULL, _libraryID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_mediaList->i_nb_items];
     for (size_t x = 0; x < p_mediaList->i_nb_items; x++) {
         VLCMediaLibraryMediaItem *mediaItem = [[VLCMediaLibraryMediaItem alloc] initWithMediaItem:&p_mediaList->p_items[x]];
@@ -526,6 +529,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 
 #pragma mark - initialization
 
+ at synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
 


=====================================
modules/gui/macosx/library/VLCLibraryInformationPanel.h
=====================================
@@ -24,14 +24,14 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
- at class VLCMediaLibraryMediaItem;
+ at protocol VLCMediaLibraryItemProtocol;
 
 @interface VLCLibraryInformationPanel : NSWindowController
 
- at property (readwrite, weak) IBOutlet NSTextField *multiLineTextLabel;
+ at property (readwrite) IBOutlet NSTextView *textView;
 @property (readwrite, weak) IBOutlet NSImageView *imageView;
 
-- (void)setRepresentedMediaItem:(VLCMediaLibraryMediaItem *)representedMediaItem;
+- (void)setRepresentedItem:(id<VLCMediaLibraryItemProtocol>)representedItem;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryInformationPanel.m
=====================================
@@ -27,7 +27,7 @@
 
 @interface VLCLibraryInformationPanel ()
 {
-    VLCMediaLibraryMediaItem *_representedMediaItem;
+    id<VLCMediaLibraryItemProtocol> _representedItem;
 }
 
 @end
@@ -39,54 +39,71 @@
     [self updateRepresentation];
 }
 
-- (void)setRepresentedMediaItem:(VLCMediaLibraryMediaItem *)representedMediaItem
+- (void)setRepresentedItem:(id<VLCMediaLibraryItemProtocol>)representedItem
 {
-    _representedMediaItem = representedMediaItem;
+    _representedItem = representedItem;
     [self updateRepresentation];
 }
 
 - (void)updateRepresentation
 {
-    NSMutableString *textContent = [[NSMutableString alloc] initWithFormat:@"Title: '%@', ID: %lli\n", _representedMediaItem.title, _representedMediaItem.libraryID];
-    if (_representedMediaItem.mediaSubType != VLC_ML_MEDIA_SUBTYPE_UNKNOWN) {
-        [textContent appendFormat:@"Type: %@ — %@\n", _representedMediaItem.readableMediaType, _representedMediaItem.readableMediaSubType];
-    } else {
-        [textContent appendFormat:@"Type: %@\n", _representedMediaItem.readableMediaType];
-    }
-    [textContent appendFormat:@"Duration: %@\n", [NSString stringWithTime:_representedMediaItem.duration / VLCMediaLibraryMediaItemDurationDenominator]];
-    [textContent appendFormat:@"Play count: %u, last played: %@\n", _representedMediaItem.playCount, [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:_representedMediaItem.lastPlayedDate] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]];
-    [textContent appendFormat:@"Small artwork generated? %@\n", _representedMediaItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No")];
-    [textContent appendFormat:@"Favorited? %@, Playback progress: %2.f%%\n", _representedMediaItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No"), _representedMediaItem.progress * 100.];
+    NSMutableString *textContent = [[NSMutableString alloc] initWithFormat:@"Title: '%@', ID: %lli\n", _representedItem.displayString, _representedItem.libraryID];
 
-    [textContent appendFormat:@"\nNumber of files: %lu\n", _representedMediaItem.files.count];
-    for (VLCMediaLibraryFile *file in _representedMediaItem.files) {
-        [textContent appendFormat:@"URL: %@\n", file.fileURL];
-        [textContent appendFormat:@"Type: %@\n", file.readableFileType];
-    }
-
-    [textContent appendFormat:@"\nNumber of tracks: %lu\n", _representedMediaItem.tracks.count];
-    for (VLCMediaLibraryTrack *track in _representedMediaItem.tracks) {
-        [textContent appendFormat:@"Type: %@\n", track.readableTrackType];
-        [textContent appendFormat:@"Codec: %@ (%@) @ %u kB/s\n", track.readableCodecName, track.codec, track.bitrate / 1024 / 8];
-        if (track.language.length > 0) {
-            [textContent appendFormat:@"Language: %@\n", track.language];
-        }
-        if (track.trackDescription.length > 0) {
-            [textContent appendFormat:@"Description: %@\n", track.trackDescription];
+    if([_representedItem isKindOfClass:[VLCMediaLibraryMediaItem class]]) {
+        VLCMediaLibraryMediaItem *mediaItem = (VLCMediaLibraryMediaItem *)_representedItem;
+        if (mediaItem.mediaSubType != VLC_ML_MEDIA_SUBTYPE_UNKNOWN) {
+            [textContent appendFormat:@"Type: %@ — %@\n", mediaItem.readableMediaType, mediaItem.readableMediaSubType];
+        } else {
+            [textContent appendFormat:@"Type: %@\n", mediaItem.readableMediaType];
         }
+        [textContent appendFormat:@"Duration: %@\n", _representedItem.durationString];
+        [textContent appendFormat:@"Play count: %u, last played: %@\n", mediaItem.playCount, [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:mediaItem.lastPlayedDate] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]];
+        [textContent appendFormat:@"Small artwork generated? %@\n", _representedItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No")];
+        [textContent appendFormat:@"Favorited? %@\n", mediaItem.favorited == YES ? _NS("Yes") : _NS("No")];
+        [textContent appendFormat:@"Playback progress: %2.f%%\n", mediaItem.progress * 100.]; // TODO: Calculate progress for other library item types
 
-        if (track.trackType == VLC_ML_TRACK_TYPE_AUDIO) {
-            [textContent appendFormat:@"Number of Channels: %u, Sample rate: %u\n", track.numberOfAudioChannels, track.audioSampleRate];
-        } else if (track.trackType == VLC_ML_TRACK_TYPE_VIDEO) {
-            [textContent appendFormat:@"Dimensions: %ux%u px, Aspect-Ratio: %2.f\n", track.videoWidth, track.videoHeight, (float)track.sourceAspectRatio / track.sourceAspectRatioDenominator];
-            [textContent appendFormat:@"Framerate: %2.f\n", (float)track.frameRate / track.frameRateDenominator];;
+        [textContent appendFormat:@"\nNumber of tracks: %lu\n", mediaItem.tracks.count];
+        for (VLCMediaLibraryTrack *track in mediaItem.tracks) {
+            [textContent appendFormat:@"Type: %@\n", track.readableTrackType];
+            [textContent appendFormat:@"Codec: %@ (%@) @ %u kB/s\n", track.readableCodecName, track.codec, track.bitrate / 1024 / 8];
+            if (track.language.length > 0) {
+                [textContent appendFormat:@"Language: %@\n", track.language];
+            }
+            if (track.trackDescription.length > 0) {
+                [textContent appendFormat:@"Description: %@\n", track.trackDescription];
+            }
+
+            if (track.trackType == VLC_ML_TRACK_TYPE_AUDIO) {
+                [textContent appendFormat:@"Number of Channels: %u, Sample rate: %u\n", track.numberOfAudioChannels, track.audioSampleRate];
+            } else if (track.trackType == VLC_ML_TRACK_TYPE_VIDEO) {
+                [textContent appendFormat:@"Dimensions: %ux%u px, Aspect-Ratio: %2.f\n", track.videoWidth, track.videoHeight, (float)track.sourceAspectRatio / track.sourceAspectRatioDenominator];
+                [textContent appendFormat:@"Framerate: %2.f\n", (float)track.frameRate / track.frameRateDenominator];
+            }
+            [textContent appendString:@"\n"];
         }
-        [textContent appendString:@"\n"];
+    } else {
+        [textContent appendFormat:@"Duration: %@\n", _representedItem.durationString];
+        [textContent appendFormat:@"Small artwork generated? %@\n", _representedItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No")];
     }
 
-    self.multiLineTextLabel.stringValue = textContent;
-    self.window.title = _representedMediaItem.title;
-    self.imageView.image = _representedMediaItem.smallArtworkImage;
+    __block NSUInteger fileCount = 0;
+    NSMutableString *fileDetails = [[NSMutableString alloc] init];
+
+    [_representedItem iterateMediaItemsWithBlock:^(VLCMediaLibraryMediaItem* mediaItem) {
+        for (VLCMediaLibraryFile *file in mediaItem.files) {
+            ++fileCount;
+            [fileDetails appendFormat:@"URL: %@\n", file.fileURL];
+            [fileDetails appendFormat:@"Type: %@\n", file.readableFileType];
+        }
+    }];
+    [textContent appendFormat:@"\nNumber of files: %lu\n", fileCount];
+    [textContent appendString: fileDetails];
+    
+    [self.textView.textStorage setAttributedString: [[NSAttributedString alloc] initWithString:textContent]];
+    self.textView.textStorage.font = [NSFont systemFontOfSize:13.];
+    self.textView.textStorage.foregroundColor = [NSColor whiteColor];
+    self.window.title = _representedItem.displayString;
+    self.imageView.image = _representedItem.smallArtworkImage;
 }
 
 @end


=====================================
modules/gui/macosx/library/VLCLibraryMenuController.m
=====================================
@@ -153,12 +153,8 @@
         _informationPanel = [[VLCLibraryInformationPanel alloc] initWithWindowNibName:@"VLCLibraryInformationPanel"];
     }
 
-    // TODO: Add handling for the other types
-    if([_representedItem isKindOfClass:[VLCMediaLibraryMediaItem class]]) {
-        VLCMediaLibraryMediaItem *mediaItem = (VLCMediaLibraryMediaItem *)_representedItem;
-        [_informationPanel setRepresentedMediaItem:mediaItem];
-        [_informationPanel showWindow:self];
-    }
+    [_informationPanel setRepresentedItem:_representedItem];
+    [_informationPanel showWindow:self];
     
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/340dd8129f91e2c3bd8cf67b1fdcf0cc8406e7e9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/340dd8129f91e2c3bd8cf67b1fdcf0cc8406e7e9
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list