瀏覽代碼

refactoring

marinofaggiana 3 年之前
父節點
當前提交
4831c75bd0

+ 8 - 2
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -72,7 +72,9 @@ class NCPlayer: NSObject {
         observerAVPlayerItemDidPlayToEndTime = NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: appDelegate.player?.currentItem, queue: .main) { (notification) in
             if let item = notification.object as? AVPlayerItem, let currentItem = self.appDelegate.player?.currentItem, item == currentItem {
                 self.videoSeek(time: .zero)
-                self.playerToolBar?.show(metadata: metadata, detailView: nil, enableTimerAutoHide: false)
+                if !(detailView?.isShow() ?? false) {
+                    self.playerToolBar?.show(enableTimerAutoHide: false)
+                }
                 NCKTVHTTPCache.shared.saveCache(metadata: metadata)
             }
         }
@@ -109,7 +111,9 @@ class NCPlayer: NSObject {
                         NCManageDatabase.shared.addVideoTime(metadata: metadata, time: nil, durationTime: durationTime)
                         self.playerToolBar?.setBarPlayer(ncplayer: self, timeSeek: timeSeek, metadata: metadata)
                         self.generatorImagePreview()
-                        self.playerToolBar?.show(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
+                        if !(detailView?.isShow() ?? false) {
+                            self.playerToolBar?.show(enableTimerAutoHide: false)
+                        }
                     }
                     break
                 case .failed:
@@ -267,6 +271,8 @@ extension NCPlayer: AVPictureInPictureControllerDelegate {
     
     func pictureInPictureControllerDidStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
         // nothing
+        if !isPlay() {
+        }
     }
 }
 

+ 6 - 8
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -37,7 +37,6 @@ class NCPlayerToolBar: UIView {
     @IBOutlet weak var playbackSlider: UISlider!
     @IBOutlet weak var labelOverallDuration: UILabel!
     @IBOutlet weak var labelCurrentTime: UILabel!
-
     
     enum sliderEventType {
         case began
@@ -53,8 +52,7 @@ class NCPlayerToolBar: UIView {
     private var durationTime: CMTime = .zero
     private var timeObserver: Any?
     private var timerAutoHide: Timer?
-    private var metadata: tableMetadata?
-
+    private var metadata: tableMetadata!
 
     // MARK: - View Life Cycle
 
@@ -112,7 +110,7 @@ class NCPlayerToolBar: UIView {
         }
     }
     
-    func setBarPlayer(ncplayer: NCPlayer, timeSeek: CMTime, metadata: tableMetadata?) {
+    func setBarPlayer(ncplayer: NCPlayer, timeSeek: CMTime, metadata: tableMetadata) {
                         
         self.ncplayer = ncplayer
         self.metadata = metadata
@@ -165,7 +163,7 @@ class NCPlayerToolBar: UIView {
         timerAutoHide = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(automaticHide), userInfo: nil, repeats: false)
     }
     
-    public func show(metadata: tableMetadata, detailView: NCViewerMediaDetailView?, enableTimerAutoHide: Bool) {
+    public func show(enableTimerAutoHide: Bool) {
         
         if metadata.classFile != NCCommunicationCommon.typeClassFile.video.rawValue && metadata.classFile != NCCommunicationCommon.typeClassFile.audio.rawValue { return }
         if metadata.livePhoto { return }
@@ -176,9 +174,9 @@ class NCPlayerToolBar: UIView {
         }
         
         if !self.isHidden { return }
-        if let detailView = detailView {
-            if detailView.isShow() { return }
-        }
+//        if let detailView = detailView {
+//            if detailView.isShow() { return }
+//        }
         
         updateToolBar()
             

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

@@ -163,7 +163,9 @@ class NCViewerMedia: UIViewController {
             navigationController?.setNavigationBarHidden(false, animated: true)
             progressView.isHidden = false
 
-            currentViewController.playerToolBar.show(metadata: currentViewController.metadata, detailView: currentViewController.detailView, enableTimerAutoHide: true)
+            if !currentViewController.detailView.isShow() {
+                currentViewController.playerToolBar.show(enableTimerAutoHide: true)
+            }
             
             NCUtility.shared.colorNavigationController(navigationController, backgroundColor: NCBrandColor.shared.systemBackground, titleColor: NCBrandColor.shared.label, tintColor: nil, withoutShadow: false)
             view.backgroundColor = NCBrandColor.shared.systemBackground

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

@@ -320,7 +320,9 @@ extension NCViewerMediaZoom {
         
         scrollView.pinchGestureRecognizer?.isEnabled = true
         if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue && !metadata.livePhoto && appDelegate.player?.timeControlStatus == .paused {
-            playerToolBar?.show(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
+            if !detailView.isShow() {
+                playerToolBar?.show(enableTimerAutoHide: false)
+            }
         }
     }