marinofaggiana 3 年之前
父节点
当前提交
6c7224c35b

+ 3 - 2
iOSClient/Data/NCManageDatabase.swift

@@ -3152,8 +3152,9 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    func getVideoDurationSeconds(metadata: tableMetadata) -> Double? {
-        
+    func getVideoDurationSeconds(metadata: tableMetadata?) -> Double? {
+        guard let metadata = metadata else { return nil }
+
         if metadata.livePhoto { return nil }
         let realm = try! Realm()
         

+ 1 - 2
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -155,8 +155,7 @@ class NCViewerImageDetailView: UIView {
                 dimValue.text = "\(Int(image.size.width)) x \(Int(image.size.height))"
             }
         } else if metadata?.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata?.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue  {
-            if let ocId = metadata?.ocId, ocId == NCViewerVideo.shared.metadata?.ocId, let duration = NCViewerVideo.shared.player?.currentItem?.asset.duration {
-                let durationSeconds = Double(CMTimeGetSeconds(duration))
+            if let ocId = metadata?.ocId, ocId == NCViewerVideo.shared.metadata?.ocId, let durationSeconds = NCManageDatabase.shared.getVideoDurationSeconds(metadata: metadata) {
                 self.dimLabel.text = NSLocalizedString("_duration_", comment: "")
                 self.dimValue.text = NCUtility.shared.stringFromTimeInterval(interval: durationSeconds)
             }