marinofaggiana 3 years ago
parent
commit
afadcc993d

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

@@ -498,38 +498,12 @@ extension NCViewerImage: UIGestureRecognizerDelegate {
     
     
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
              
              
-        if !currentMetadata.livePhoto {
-            if let viewerVideoToolBar = currentViewerImageZoom?.videoToolBar {
-                if viewerVideoToolBar.isHidden {
-                    viewerVideoToolBar.showToolBar()
-                    return
-                }
+        if let viewerVideoToolBar = currentViewerImageZoom?.videoToolBar {
+            if viewerVideoToolBar.showToolBar(metadata: currentMetadata) {
+                return
             }
             }
         }
         }
-            
-        /*
-        if currentMetadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || currentMetadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
-            
-            if self.viewerVideo?.pictureInPictureOcId != currentMetadata.ocId {
-                   
-                // Kill PIP
-                appDelegate.activeViewerAVPlayerViewController?.player?.replaceCurrentItem(with: nil)
-                // --------
-                
-                appDelegate.activeViewerAVPlayerViewController = NCViewerAVPlayerViewController()
-                appDelegate.activeViewerAVPlayerViewController?.metadata = currentMetadata
-                appDelegate.activeViewerAVPlayerViewController?.imageBackground = UIImage(named: "file_audio")
-                appDelegate.activeViewerAVPlayerViewController?.delegateViewerVideo = self
-                if let currentViewerVideo = appDelegate.activeViewerAVPlayerViewController {
-                    present(currentViewerVideo, animated: false) { }
-                    
-                }
-            }
-            
-            currentMode = .full
-        }
-        */
-                
+
         if currentMode == .full {
         if currentMode == .full {
             
             
             navigationController?.setNavigationBarHidden(false, animated: false)
             navigationController?.setNavigationBarHidden(false, animated: false)

+ 1 - 3
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -268,9 +268,7 @@ extension NCViewerImageZoom {
         
         
         scrollView.pinchGestureRecognizer?.isEnabled = true
         scrollView.pinchGestureRecognizer?.isEnabled = true
         
         
-        if !metadata.livePhoto {
-            videoToolBar.showToolBar()
-        }
+        videoToolBar.showToolBar(metadata: metadata)
     }
     }
 }
 }
 
 

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

@@ -69,7 +69,7 @@ class NCViewerVideo: NSObject {
             NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: self.player?.currentItem, queue: .main) { (notification) in
             NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: self.player?.currentItem, queue: .main) { (notification) in
                 if let item = notification.object as? AVPlayerItem, let currentItem = self.player?.currentItem, item == currentItem {
                 if let item = notification.object as? AVPlayerItem, let currentItem = self.player?.currentItem, item == currentItem {
                     self.player?.seek(to: .zero)
                     self.player?.seek(to: .zero)
-                    self.viewerVideoToolBar?.showToolBar()
+                    self.viewerVideoToolBar?.showToolBar(metadata: metadata)
                     NCKTVHTTPCache.shared.saveCache(metadata: metadata)
                     NCKTVHTTPCache.shared.saveCache(metadata: metadata)
                 }
                 }
             }
             }

+ 20 - 8
iOSClient/Viewer/NCViewerVideo/NCViewerVideoToolBar.swift

@@ -115,15 +115,27 @@ class NCViewerVideoToolBar: UIView {
         })
         })
     }
     }
     
     
-    @objc public func showToolBar() {
+    @discardableResult
+    @objc public func showToolBar(metadata: tableMetadata) -> Bool {
         
         
-        updateToolBar()
-        
-        UIView.animate(withDuration: 0.3, animations: {
-            self.alpha = 1
-        }, completion: { (value: Bool) in
-            self.isHidden = false
-        })
+        if !self.isHidden { return false}
+        if metadata.livePhoto { return false}
+        if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
+            
+            updateToolBar()
+            
+            UIView.animate(withDuration: 0.3, animations: {
+                self.alpha = 1
+            }, completion: { (value: Bool) in
+                self.isHidden = false
+            })
+            
+            return true
+            
+        } else {
+            
+            return false
+        }
     }
     }
     
     
     public func updateToolBar() {
     public func updateToolBar() {