marinofaggiana 4 years ago
parent
commit
5cbb039b3a

+ 8 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -2281,7 +2281,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2336,7 +2336,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2383,7 +2383,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2431,7 +2431,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2485,7 +2485,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2539,7 +2539,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2585,7 +2585,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2634,7 +2634,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (

+ 7 - 5
iOSClient/Data/NCManageDatabase.swift

@@ -2793,8 +2793,9 @@ class NCManageDatabase: NSObject {
     //MARK: -
     //MARK: Table Video
     
-    func addVideoTime(account: String, ocId: String, time: CMTime?) {
+    func addVideoTime(metadata: tableMetadata, time: CMTime?) {
         
+        if metadata.livePhoto { return }
         guard let time = time else { return }
         let realm = try! Realm()
         
@@ -2802,8 +2803,8 @@ class NCManageDatabase: NSObject {
             try realm.safeWrite {
                 let addObject = tableVideo()
                
-                addObject.account = account
-                addObject.ocId = ocId
+                addObject.account = metadata.account
+                addObject.ocId = metadata.ocId
                 addObject.time = Int64(CMTimeGetSeconds(time) * 1000)
               
                 realm.add(addObject, update: .all)
@@ -2813,11 +2814,12 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    func getVideoTime(account: String, ocId: String) -> CMTime? {
+    func getVideoTime(metadata: tableMetadata) -> CMTime? {
         
+        if metadata.livePhoto { return CMTime.zero }
         let realm = try! Realm()
         
-        guard let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", account, ocId).first else {
+        guard let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", metadata.account, metadata.ocId).first else {
             return nil
         }
         

+ 8 - 4
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -309,7 +309,11 @@ class NCViewerImage: UIViewController {
             
             currentViewerImageZoom?.statusViewImage.isHidden = false
             currentViewerImageZoom?.statusLabel.isHidden = false
-            videoStop()
+            
+            let fileName = (currentMetadata.fileNameView as NSString).deletingPathExtension + ".mov"
+            if NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", currentMetadata.account, currentMetadata.serverUrl, fileName)) != nil {
+                videoStop()
+            }
         }
     }
     
@@ -418,7 +422,7 @@ class NCViewerImage: UIViewController {
                 NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player?.currentItem, queue: .main) { (notification) in
                     if let item = notification.object as? AVPlayerItem, let currentItem = self.player?.currentItem, item == currentItem {
                         self.player?.seek(to: CMTime.zero)
-                        NCManageDatabase.shared.addVideoTime(account: self.currentMetadata.account, ocId: self.currentMetadata.ocId, time: CMTime.zero)
+                        NCManageDatabase.shared.addVideoTime(metadata: self.currentMetadata, time: CMTime.zero)
                     }
                 }
                             
@@ -458,12 +462,12 @@ class NCViewerImage: UIViewController {
             setToolBar()
             
             if ((player?.rate) == 1) {
-                if let time = NCManageDatabase.shared.getVideoTime(account: self.currentMetadata.account, ocId: self.currentMetadata.ocId) {
+                if let time = NCManageDatabase.shared.getVideoTime(metadata: self.currentMetadata) {
                     player?.seek(to: time)
                     player?.isMuted = CCUtility.getAudioMute()
                 }
             } else {
-                NCManageDatabase.shared.addVideoTime(account: self.currentMetadata.account, ocId: self.currentMetadata.ocId, time: player?.currentTime())
+                NCManageDatabase.shared.addVideoTime(metadata: self.currentMetadata, time: player?.currentTime())
                 print("Pause")
             }
         }

+ 3 - 3
iOSClient/Viewer/NCViewerVideo/NCViewerVideo.swift

@@ -61,7 +61,7 @@ protocol NCViewerVideoDelegate {
             rateObserverToken = player?.addObserver(self, forKeyPath: "rate", options: [], context: nil)
             
             player?.play()
-            if let time = NCManageDatabase.shared.getVideoTime(account: self.metadata.account, ocId: self.metadata.ocId) {
+            if let time = NCManageDatabase.shared.getVideoTime(metadata: self.metadata) {
                 player?.seek(to: time)
             }
             player?.isMuted = CCUtility.getAudioMute()
@@ -71,7 +71,7 @@ protocol NCViewerVideoDelegate {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         
-        NCManageDatabase.shared.addVideoTime(account: metadata.account, ocId: metadata.ocId, time: player?.currentTime())
+        NCManageDatabase.shared.addVideoTime(metadata: metadata, time: player?.currentTime())
         
         if let player = self.player {
             CCUtility.setAudioMute(player.isMuted)
@@ -109,7 +109,7 @@ extension NCViewerVideo: AVPlayerViewControllerDelegate {
     }
     
     func playerViewControllerWillStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
-        NCManageDatabase.shared.addVideoTime(account: metadata.account, ocId: metadata.ocId, time: player?.currentTime())
+        NCManageDatabase.shared.addVideoTime(metadata: metadata, time: player?.currentTime())
         pictureInPicture = false
         let playing = player?.timeControlStatus == .playing
         delegateViewerVideo?.stopPictureInPicture(metadata: metadata, playing: playing)