From 98e4fda6165001935a58ab04ee9e198c92d872db Mon Sep 17 00:00:00 2001 From: Soomin Lee Date: Tue, 31 Jul 2018 14:59:53 +0200 Subject: [PATCH] VLCPlaylistCollectionViewCell: Handle formatting inside modelview --- SharedSources/MediaLibraryModel/VideoModel.swift | 9 +++++++++ Sources/VLCPlaylistCollectionViewCell.m | 7 ++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SharedSources/MediaLibraryModel/VideoModel.swift b/SharedSources/MediaLibraryModel/VideoModel.swift index 88927b39..29806d68 100644 --- a/SharedSources/MediaLibraryModel/VideoModel.swift +++ b/SharedSources/MediaLibraryModel/VideoModel.swift @@ -36,3 +36,12 @@ extension VideoModel: MediaLibraryObserver { updateView?() } } + +extension VLCMLMedia { + @objc func formatDuration(ofMedia media: VLCMLMedia) -> String { + return String(format: "%@ - %@", + VLCTime(int: Int32(media.duration())), + ByteCountFormatter.string(fromByteCount: Int64(media.mainFile().size()), + countStyle: .file)) + } +} diff --git a/Sources/VLCPlaylistCollectionViewCell.m b/Sources/VLCPlaylistCollectionViewCell.m index f466e2fc..79de3766 100644 --- a/Sources/VLCPlaylistCollectionViewCell.m +++ b/Sources/VLCPlaylistCollectionViewCell.m @@ -16,8 +16,7 @@ #import "VLCPlaylistCollectionViewCell.h" #import "VLCThumbnailsCache.h" #import "NSString+SupportedMedia.h" - -#import +#import "VLC-Swift.h" @interface VLCPlaylistCollectionViewCell () { @@ -211,9 +210,7 @@ - (void)_updateDisplayedInformations { _titleLabel.text = _media.title; - _subtitleLabel.text = [NSString stringWithFormat:@"%@ — %@", [VLCTime timeWithNumber:[NSNumber numberWithLongLong:_media.duration]], - [NSByteCountFormatter stringFromByteCount:[_media.mainFile size] countStyle:NSByteCountFormatterCountStyleFile]]; - + _subtitleLabel.text = [_media formatDurationOfMedia:_media]; } - (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath -- 2.22.0