diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m index d06c0728b2d0b0be6735e5813655ebb75e419c02..a4b1aa2523c3604b42dd6eccabb0e24931711c7d 100644 --- a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m +++ b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m @@ -142,12 +142,31 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95; - (void)updateRepresentation { if (_representedMediaItem == nil) { + NSAssert(1, @"no media item assigned for collection view item", nil); return; } _mediaTitleTextField.stringValue = _representedMediaItem.title; - _durationTextField.stringValue = [NSString stringWithTime:_representedMediaItem.duration / 1000]; + _durationTextField.stringValue = [NSString stringWithTime:_representedMediaItem.duration / VLCMediaLibraryMediaItemDurationDenominator]; + _mediaImageView.image = [self imageForMedia]; + + VLCMediaLibraryTrack *videoTrack = _representedMediaItem.firstVideoTrack; + [self showVideoSizeIfNeededForWidth:videoTrack.videoWidth andHeight:videoTrack.videoHeight]; + + CGFloat position = _representedMediaItem.lastPlaybackPosition; + if (position > VLCLibraryCollectionViewItemMinimalDisplayedProgress && position < VLCLibraryCollectionViewItemMaximumDisplayedProgress) { + _progressIndicator.progress = position; + _progressIndicator.hidden = NO; + } + + if (_representedMediaItem.playCount == 0) { + _unplayedIndicatorTextField.hidden = NO; + } +} + +- (NSImage *)imageForMedia +{ NSImage *image; if (_representedMediaItem.artworkGenerated) { image = [[NSImage alloc] initWithContentsOfURL:[NSURL URLWithString:_representedMediaItem.artworkMRL]]; @@ -159,11 +178,11 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95; if (!image) { image = [NSImage imageNamed: @"noart.png"]; } - _mediaImageView.image = image; + return image; +} - VLCMediaLibraryTrack *videoTrack = _representedMediaItem.firstVideoTrack; - CGFloat width = videoTrack.videoWidth; - CGFloat height = videoTrack.videoHeight; +- (void)showVideoSizeIfNeededForWidth:(CGFloat)width andHeight:(CGFloat)height +{ if (width >= VLCMediaLibrary4KWidth || height >= VLCMediaLibrary4KHeight) { _annotationTextField.stringValue = @" 4K "; _annotationTextField.hidden = NO; @@ -171,16 +190,6 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95; _annotationTextField.stringValue = @" HD "; _annotationTextField.hidden = NO; } - - CGFloat position = _representedMediaItem.lastPlaybackPosition; - if (position > VLCLibraryCollectionViewItemMinimalDisplayedProgress && position < VLCLibraryCollectionViewItemMaximumDisplayedProgress) { - _progressIndicator.progress = position; - _progressIndicator.hidden = NO; - } - - if (_representedMediaItem.playCount == 0) { - _unplayedIndicatorTextField.hidden = NO; - } } #pragma mark - actions diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h index 8fb75bc8a82c9e11f0214359ef03a03141fb593b..5d50c69e5bbe3272724efddb96a8353cc593bdb7 100644 --- a/modules/gui/macosx/library/VLCLibraryDataTypes.h +++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h @@ -31,6 +31,7 @@ extern const CGFloat VLCMediaLibrary4KWidth; extern const CGFloat VLCMediaLibrary4KHeight; extern const CGFloat VLCMediaLibrary720pWidth; extern const CGFloat VLCMediaLibrary720pHeight; +extern const long long int VLCMediaLibraryMediaItemDurationDenominator; @interface VLCMediaLibraryFile : NSObject diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m index af99634fd25564cf7a37c8d26784b33afde68f0e..76ec78fd4ecbf381f8c1930d488fafc7a7e8e2f9 100644 --- a/modules/gui/macosx/library/VLCLibraryDataTypes.m +++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m @@ -31,6 +31,7 @@ const CGFloat VLCMediaLibrary4KWidth = 3840.; const CGFloat VLCMediaLibrary4KHeight = 2160.; const CGFloat VLCMediaLibrary720pWidth = 1280.; const CGFloat VLCMediaLibrary720pHeight = 720.; +const long long int VLCMediaLibraryMediaItemDurationDenominator = 1000; @implementation VLCMediaLibraryFile