marinofaggiana 3 年之前
父節點
當前提交
4198a25ab5

+ 2 - 0
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -129,6 +129,8 @@ class NCViewerImage: UIViewController {
     
     
     override func viewWillDisappear(_ animated: Bool) {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         super.viewWillDisappear(animated)
+        
+        NCViewerVideo.shared.videoRemoved()
                    
                    
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDeleteFile), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDeleteFile), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil)

+ 2 - 5
iOSClient/Viewer/NCViewerVideo/NCViewerVideo.swift

@@ -113,10 +113,7 @@ class NCViewerVideo: NSObject {
     }
     }
     
     
     func videoSeek(time: CMTime) {
     func videoSeek(time: CMTime) {
-        guard let metadata = self.metadata else { return }
-
         self.player?.seek(to: time)
         self.player?.seek(to: time)
-        NCManageDatabase.shared.addVideoTime(metadata: metadata, time: time, durationSeconds: nil)
     }
     }
     
     
     func videoRemoved() {
     func videoRemoved() {
@@ -176,10 +173,10 @@ class NCViewerVideo: NSObject {
                     let timeSecond = Double(CMTimeGetSeconds(time))
                     let timeSecond = Double(CMTimeGetSeconds(time))
                     let durationSeconds = Double(CMTimeGetSeconds(duration))
                     let durationSeconds = Double(CMTimeGetSeconds(duration))
                     if timeSecond < durationSeconds {
                     if timeSecond < durationSeconds {
-                        NCManageDatabase.shared.addVideoTime(metadata: metadata, time: self.player?.currentTime(), durationSeconds: nil)
                         if let time = self.player?.currentTime() {
                         if let time = self.player?.currentTime() {
+                            NCManageDatabase.shared.addVideoTime(metadata: metadata, time: time, durationSeconds: nil)
                             let timeSecond = Double(CMTimeGetSeconds(time))
                             let timeSecond = Double(CMTimeGetSeconds(time))
-                            print("Stop video at: \(timeSecond)")
+                            print("Save video time: \(timeSecond)")
                         }
                         }
                     } else {
                     } else {
                         NCManageDatabase.shared.deleteVideoTime(metadata: metadata)
                         NCManageDatabase.shared.deleteVideoTime(metadata: metadata)