marinofaggiana 3 years ago
parent
commit
ff61018438

+ 6 - 6
iOSClient/Data/NCManageDatabase.swift

@@ -3138,10 +3138,10 @@ class NCManageDatabase: NSObject {
                 if let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", metadata.account, metadata.ocId).first {
                     
                     if let durationTime = durationTime {
-                        result.duration = durationTime.value
+                        result.duration = durationTime.convertScale(1000, method: .default).value
                     }
                     if let time = time {
-                        result.time = time.value
+                        result.time = time.convertScale(1000, method: .default).value
                     }
                     realm.add(result, update: .all)
 
@@ -3151,11 +3151,11 @@ class NCManageDatabase: NSObject {
                    
                     addObject.account = metadata.account
                     if let durationTime = durationTime {
-                        addObject.duration = durationTime.value //Int64(CMTimeGetSeconds(duration)) * 1000
+                        addObject.duration = durationTime.convertScale(1000, method: .default).value
                     }
                     addObject.ocId = metadata.ocId
                     if let time = time {
-                        addObject.time = time.value //Int64(CMTimeGetSeconds(time)) * 1000
+                        addObject.time = time.convertScale(1000, method: .default).value
                     }
                     realm.add(addObject, update: .all)
                 }
@@ -3176,7 +3176,7 @@ class NCManageDatabase: NSObject {
         }
         
         if result.duration == 0 { return nil }
-        let duration = CMTimeMake(value: result.duration, timescale: 0)
+        let duration = CMTimeMake(value: result.duration, timescale: 1000)
         return duration
     }
     
@@ -3190,7 +3190,7 @@ class NCManageDatabase: NSObject {
         }
         
         if result.time == 0 { return nil }
-        let time = CMTimeMake(value: result.time, timescale: 0)
+        let time = CMTimeMake(value: result.time, timescale: 1000)
         return time
     }
     

+ 0 - 3
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -88,9 +88,6 @@ class NCPlayer: NSObject {
                             imageVideoContainer.metadata = self.metadata
                         }
                         NCManageDatabase.shared.addVideoTime(metadata: metadata, time: nil, durationTime: durationTime)
-
-//                        self.durationSeconds = CMTimeGetSeconds(duration)
-//                        self.saveDurationSeconds(self.durationSeconds)
                         self.playerToolBar?.setBarPlayer(ncplayer: self)
                         self.generatorImagePreview()
                     }

+ 2 - 1
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -154,7 +154,8 @@ class NCPlayerToolBar: UIView {
 
         var namedPlay = "play.fill"
         let durationTime = NCManageDatabase.shared.getVideoDurationTime(metadata: ncplayer?.metadata) ?? .zero
-        let currentTime = ncplayer?.player?.currentTime() ?? .zero
+        var currentTime = ncplayer?.player?.currentTime() ?? .zero
+        currentTime = currentTime.convertScale(1000, method: .default)
         
         if ncplayer?.player?.rate == 1 { namedPlay = "pause.fill"}