浏览代码

VLCPlaylistCollectionViewCell: Handle formatting inside modelview

Soomin Lee 7 年之前
父节点
当前提交
98e4fda616
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. 9 0
      SharedSources/MediaLibraryModel/VideoModel.swift
  2. 2 5
      Sources/VLCPlaylistCollectionViewCell.m

+ 9 - 0
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))
+    }
+}

+ 2 - 5
Sources/VLCPlaylistCollectionViewCell.m

@@ -16,8 +16,7 @@
 #import "VLCPlaylistCollectionViewCell.h"
 #import "VLCThumbnailsCache.h"
 #import "NSString+SupportedMedia.h"
-
-#import <VLCMediaLibraryKit/VLCMLFile.h>
+#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