marinofaggiana 3 years ago
parent
commit
dbd19b6f5e

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

@@ -435,8 +435,7 @@ extension NCViewerImage: UIPageViewControllerDelegate, UIPageViewControllerDataS
         
         
         guard let nextViewController = pendingViewControllers.first as? NCViewerImageZoom else { return }
         guard let nextViewController = pendingViewControllers.first as? NCViewerImageZoom else { return }
         nextIndex = nextViewController.index
         nextIndex = nextViewController.index
-        // STOP VIDEO
-//        NCViewerVideo.shared.videoStop()
+        NCViewerVideo.shared.videoPause()
     }
     }
     
     
     func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
     func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
@@ -504,7 +503,7 @@ extension NCViewerImage: UIGestureRecognizerDelegate {
                     return
                     return
                 }
                 }
             }
             }
-        }        
+        }
             
             
         /*
         /*
         if currentMetadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || currentMetadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
         if currentMetadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || currentMetadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {

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

@@ -81,16 +81,10 @@ class NCViewerImageZoom: UIViewController {
             if !metadata.livePhoto {
             if !metadata.livePhoto {
                 videoToolBar.isHidden = false
                 videoToolBar.isHidden = false
             }
             }
-            DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-                NCViewerVideo.shared.initVideoPlayer(imageView: self.imageView, viewerVideoToolBar: self.videoToolBar, metadata: self.metadata)
-            }
         } else if metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
         } else if metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
             if image == nil {
             if image == nil {
                 image = UIImage.init(named: "noPreviewAudio")!.image(color: .gray, size: view.frame.width)
                 image = UIImage.init(named: "noPreviewAudio")!.image(color: .gray, size: view.frame.width)
             }
             }
-            DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-                NCViewerVideo.shared.initVideoPlayer(imageView: self.imageView, viewerVideoToolBar: self.videoToolBar, metadata: self.metadata)
-            }
         } else {
         } else {
             if image == nil {
             if image == nil {
                 image = UIImage.init(named: "noPreview")!.image(color: .gray, size: view.frame.width)
                 image = UIImage.init(named: "noPreview")!.image(color: .gray, size: view.frame.width)
@@ -120,12 +114,10 @@ class NCViewerImageZoom: UIViewController {
         super.viewDidAppear(animated)
         super.viewDidAppear(animated)
         
         
         delegate?.didAppearImageZoom(viewerImageZoom: self, metadata: metadata)
         delegate?.didAppearImageZoom(viewerImageZoom: self, metadata: metadata)
-    }
-    
-    override func viewDidDisappear(_ animated: Bool) {
-        super.viewDidDisappear(animated)
         
         
-//        NCViewerVideo.shared.videoStop()
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
+            NCViewerVideo.shared.initVideoPlayer(imageView: self.imageView, viewerVideoToolBar: self.videoToolBar, metadata: self.metadata)
+        }
     }
     }
     
     
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

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

@@ -53,13 +53,12 @@ class NCViewerVideo: NSObject {
     
     
     func initVideoPlayer(imageView: UIImageView?, viewerVideoToolBar: NCViewerVideoToolBar?, metadata: tableMetadata) {
     func initVideoPlayer(imageView: UIImageView?, viewerVideoToolBar: NCViewerVideoToolBar?, metadata: tableMetadata) {
         guard let imageView = imageView else { return }
         guard let imageView = imageView else { return }
-       
+        if self.imageView == imageView { return }
+        
         self.imageView = imageView
         self.imageView = imageView
         self.viewerVideoToolBar = viewerVideoToolBar
         self.viewerVideoToolBar = viewerVideoToolBar
         self.metadata = metadata
         self.metadata = metadata
                 
                 
-        NCKTVHTTPCache.shared.startProxy(user: appDelegate.user, password: appDelegate.password, metadata: metadata)
-        
         func initPlayer(url: URL) {
         func initPlayer(url: URL) {
                         
                         
             self.player = AVPlayer(url: url)
             self.player = AVPlayer(url: url)
@@ -96,14 +95,13 @@ class NCViewerVideo: NSObject {
         
         
         if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
         if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
             initPlayer(url: url)
             initPlayer(url: url)
-        }
-        
-        //
+        }        
     }
     }
     
     
     func videoPlay() {
     func videoPlay() {
         guard let metadata = self.metadata else { return }
         guard let metadata = self.metadata else { return }
         
         
+        NCKTVHTTPCache.shared.startProxy(user: appDelegate.user, password: appDelegate.password, metadata: metadata)
         self.player?.play()
         self.player?.play()
     }
     }
     
     
@@ -111,6 +109,7 @@ class NCViewerVideo: NSObject {
         guard let metadata = self.metadata else { return }
         guard let metadata = self.metadata else { return }
         
         
         self.player?.pause()
         self.player?.pause()
+        NCKTVHTTPCache.shared.stopProxy(metadata: metadata)
     }
     }
     
     
     func videoSeek(time: CMTime) {
     func videoSeek(time: CMTime) {

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

@@ -133,6 +133,7 @@ class NCViewerVideoToolBar: UIView {
         let currentSeconds = NCViewerVideo.shared.getVideoCurrentSeconds()
         let currentSeconds = NCViewerVideo.shared.getVideoCurrentSeconds()
         let durationSeconds = NCViewerVideo.shared.getVideoDurationSeconds()
         let durationSeconds = NCViewerVideo.shared.getVideoDurationSeconds()
         
         
+        playbackSlider.value = Float(currentSeconds)
         playbackSlider.isEnabled = true
         playbackSlider.isEnabled = true
         
         
         backButton.setImage(NCUtility.shared.loadImage(named: "gobackward.15", color: .white), for: .normal)
         backButton.setImage(NCUtility.shared.loadImage(named: "gobackward.15", color: .white), for: .normal)
@@ -155,8 +156,8 @@ class NCViewerVideoToolBar: UIView {
         }
         }
         muteButton.isEnabled = true
         muteButton.isEnabled = true
         
         
-        self.labelCurrentTime.text = NCUtility.shared.stringFromTimeInterval(interval: currentSeconds)
-        self.labelOverallDuration.text = "-" + NCUtility.shared.stringFromTimeInterval(interval: durationSeconds - currentSeconds)
+        labelCurrentTime.text = NCUtility.shared.stringFromTimeInterval(interval: currentSeconds)
+        labelOverallDuration.text = "-" + NCUtility.shared.stringFromTimeInterval(interval: durationSeconds - currentSeconds)
     }
     }
     
     
     //MARK: - Event / Gesture
     //MARK: - Event / Gesture