marinofaggiana 3 lat temu
rodzic
commit
7112630a6e

+ 1 - 1
iOSClient/AppDelegate.swift

@@ -331,7 +331,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     func setAVAudioSession() {
         do {
             try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSession.PortOverride.none)
-            try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .allowAirPlay])
+            try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback, options: [.mixWithOthers, .allowAirPlay])
             try AVAudioSession.sharedInstance().setActive(true)
         } catch {
             print(error)

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

@@ -67,7 +67,7 @@ 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?.showToolBar(metadata: metadata, detailView: nil, enableTimerAutoHide: false)
+                self.playerToolBar?.show(metadata: metadata, detailView: nil, enableTimerAutoHide: false)
                 NCKTVHTTPCache.shared.saveCache(metadata: metadata)
             }
         }
@@ -99,7 +99,7 @@ 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?.showToolBar(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
+                        self.playerToolBar?.show(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
                     }
                     break
                 case .failed:

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

@@ -127,7 +127,7 @@ class NCPlayerToolBar: UIView {
         })        
     }
     
-    public func hideToolBar() {
+    public func hide() {
               
         UIView.animate(withDuration: 0.3, animations: {
             self.alpha = 0
@@ -136,7 +136,7 @@ class NCPlayerToolBar: UIView {
         })
     }
     
-    @objc private func automaticHideToolBar() {
+    @objc private func automaticHide() {
         
         if let metadata = self.metadata {
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterHidePlayerToolBar, userInfo: ["ocId":metadata.ocId])
@@ -146,10 +146,10 @@ class NCPlayerToolBar: UIView {
     private func startTimerAutoHide() {
         
         timerAutoHide?.invalidate()
-        timerAutoHide = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(automaticHideToolBar), userInfo: nil, repeats: false)
+        timerAutoHide = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(automaticHide), userInfo: nil, repeats: false)
     }
     
-    public func showToolBar(metadata: tableMetadata, detailView: NCViewerMediaDetailView?, enableTimerAutoHide: Bool) {
+    public func show(metadata: tableMetadata, detailView: NCViewerMediaDetailView?, enableTimerAutoHide: Bool) {
         
         if metadata.classFile != NCCommunicationCommon.typeClassFile.video.rawValue && metadata.classFile != NCCommunicationCommon.typeClassFile.audio.rawValue { return }
         if metadata.livePhoto { return }
@@ -173,6 +173,10 @@ class NCPlayerToolBar: UIView {
         })
     }
     
+    func isShow() -> Bool {
+        return !self.isHidden
+    }
+    
     public func updateToolBar(timeSeek: CMTime? = nil) {
 
         var namedPlay = "play.fill"
@@ -251,7 +255,7 @@ class NCPlayerToolBar: UIView {
     
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
         
-        hideToolBar()
+        hide()
     }
     
     //MARK: - Action

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

@@ -164,7 +164,7 @@ class NCViewerMedia: UIViewController {
             navigationController?.setNavigationBarHidden(false, animated: true)
             progressView.isHidden = false
 
-            currentViewController.playerToolBar.showToolBar(metadata: currentViewController.metadata, detailView: currentViewController.detailView, enableTimerAutoHide: true)
+            currentViewController.playerToolBar.show(metadata: currentViewController.metadata, detailView: currentViewController.detailView, enableTimerAutoHide: true)
             
             NCUtility.shared.colorNavigationController(navigationController, backgroundColor: NCBrandColor.shared.systemBackground, titleColor: NCBrandColor.shared.label, tintColor: nil, withoutShadow: false)
             view.backgroundColor = NCBrandColor.shared.systemBackground
@@ -175,7 +175,7 @@ class NCViewerMedia: UIViewController {
             navigationController?.setNavigationBarHidden(true, animated: true)
             progressView.isHidden = true
             
-            currentViewController.playerToolBar.hideToolBar()
+            currentViewController.playerToolBar.hide()
 
             view.backgroundColor = .black
             textColor = .white

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

@@ -189,7 +189,7 @@ class NCViewerMediaZoom: UIViewController {
         if detailView.isShow() { return }
         
         // NO ZOOM for Audio / Video
-        if (metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue) && !playerToolBar.isHidden {
+        if (metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue) && playerToolBar.isShow() {
             return
         }
         
@@ -301,7 +301,7 @@ extension NCViewerMediaZoom {
             }
                 
             self.scrollView.pinchGestureRecognizer?.isEnabled = false
-            self.playerToolBar.hideToolBar()
+            self.playerToolBar.hide()
         }
     }
     
@@ -320,7 +320,7 @@ extension NCViewerMediaZoom {
         
         scrollView.pinchGestureRecognizer?.isEnabled = true
         if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue && !metadata.livePhoto && appDelegate.player?.timeControlStatus == .paused {
-            playerToolBar?.showToolBar(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
+            playerToolBar?.show(metadata: metadata, detailView: detailView, enableTimerAutoHide: false)
         }
     }