marinofaggiana 3 years ago
parent
commit
8396fa9385

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -324,7 +324,7 @@ class NCGlobal: NSObject {
     
     let notificationCenterDownloadedThumbnail                   = "DownloadedThumbnail"             // userInfo: ocId
     
-    let notificationCenterHidePlayerToolBar                     = "hidePlayerToolBar"               // userInfo:
+    let notificationCenterHidePlayerToolBar                     = "hidePlayerToolBar"               // userInfo: ocId
 }
 
 //let rootView = UIApplication.shared.keyWindow?.rootViewController?.view

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

@@ -96,7 +96,7 @@ class NCPlayer: NSObject {
                             }
                         }
                         NCManageDatabase.shared.addVideoTime(metadata: metadata, time: nil, durationTime: durationTime)
-                        self.playerToolBar?.setBarPlayer(ncplayer: self, timeSeek: timeSeek)
+                        self.playerToolBar?.setBarPlayer(ncplayer: self, timeSeek: timeSeek, metadata: metadata)
                         self.generatorImagePreview()
                         self.playerToolBar?.showToolBar(metadata: metadata, detailView: detailView)
                     }

+ 9 - 3
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -49,6 +49,7 @@ class NCPlayerToolBar: UIView {
     private var durationTime: CMTime = .zero
     private var timeObserver: Any?
     private var timerAutoHide: Timer?
+    private var metadata: tableMetadata?
 
 
     // MARK: - View Life Cycle
@@ -97,9 +98,11 @@ class NCPlayerToolBar: UIView {
         }
     }
     
-    func setBarPlayer(ncplayer: NCPlayer, timeSeek: CMTime) {
+    func setBarPlayer(ncplayer: NCPlayer, timeSeek: CMTime, metadata: tableMetadata?) {
                         
         self.ncplayer = ncplayer
+        self.metadata = metadata
+        
         if let durationTime = NCManageDatabase.shared.getVideoDurationTime(metadata: ncplayer.metadata) {
         
             self.durationTime = durationTime
@@ -135,12 +138,15 @@ class NCPlayerToolBar: UIView {
     
     @objc private func automaticHideToolBar() {
         
-        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterHidePlayerToolBar)
+        if let metadata = self.metadata {
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterHidePlayerToolBar, userInfo: ["ocId":metadata.ocId])
+        }
     }
     
     public func showToolBar(metadata: tableMetadata, detailView: NCViewerMediaDetailView?) {
         
-        if metadata.classFile != NCCommunicationCommon.typeClassFile.video.rawValue && metadata.classFile != NCCommunicationCommon.typeClassFile.audio.rawValue && metadata.livePhoto { return }
+        if metadata.classFile != NCCommunicationCommon.typeClassFile.video.rawValue && metadata.classFile != NCCommunicationCommon.typeClassFile.audio.rawValue { return }
+        if metadata.livePhoto { return }
         
         timerAutoHide?.invalidate()
         timerAutoHide = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(automaticHideToolBar), userInfo: nil, repeats: false)

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

@@ -308,7 +308,12 @@ class NCViewerMedia: UIViewController {
     }
     
     @objc func hidePlayerToolBar(_ notification: NSNotification) {
-        changeScreenMode(mode: .full)
+        
+        if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String {
+            if currentViewController.metadata.ocId == ocId {
+                changeScreenMode(mode: .full)
+            }
+        }
     }
     
     //MARK: - Image