marinofaggiana 3 жил өмнө
parent
commit
d0a86a6776

+ 7 - 3
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -132,9 +132,13 @@ class NCViewerMedia: UIViewController {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         
-        currentViewerMediaZoom?.ncplayer?.videoPause()
-        currentViewerMediaZoom?.ncplayer?.saveCurrentTime()
-
+        if let player = appDelegate.player, let time = appDelegate.player?.currentTime() {
+            if player.rate == 1 {
+                player.pause()
+                NCManageDatabase.shared.addVideoTime(metadata: currentMetadata, time: time, durationSeconds: 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.notificationCenterMoveFile), object: nil)

+ 10 - 3
iOSClient/Viewer/NCViewerMedia/NCViewerMediaZoom.swift

@@ -41,6 +41,7 @@ class NCViewerMediaZoom: UIViewController {
     @IBOutlet weak var detailView: NCViewerMediaDetailView!
     @IBOutlet weak var playerToolBar: NCPlayerToolBar!
     
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var delegate: NCViewerMediaZoomDelegate?
     var viewerMedia: NCViewerMedia?
     var ncplayer: NCPlayer?
@@ -117,17 +118,23 @@ class NCViewerMediaZoom: UIViewController {
         viewerMedia?.navigationItem.title = metadata.fileNameView
         viewerMedia?.currentViewerMediaZoom = self
         viewerMedia?.currentMetadata = metadata
-
         
+        self.appDelegate.player?.pause()
+
         if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue,  let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
             
             self.ncplayer = NCPlayer.init(url: url)
             self.viewerMedia?.ncplayer = self.ncplayer
-            self.ncplayer?.setupVideoLayer(imageVideoContainer: self.imageVideoContainer, playerToolBar: self.playerToolBar, metadata: self.metadata)
-            //self.player?.videoPlay()
         }
     }
     
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+        
+        self.ncplayer?.setupVideoLayer(imageVideoContainer: self.imageVideoContainer, playerToolBar: self.playerToolBar, metadata: self.metadata)
+        //self.player?.videoPlay()
+    }
+    
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)