Marino Faggiana 1 سال پیش
والد
کامیت
4a1840f01f

+ 0 - 4
iOSClient/NCGlobal.swift

@@ -367,10 +367,6 @@ class NCGlobal: NSObject {
     let notificationCenterShowPlayerToolBar                     = "showPlayerToolBar"               // userInfo: ocId, enableTimerAutoHide
     let notificationCenterOpenMediaDetail                       = "openMediaDetail"                 // userInfo: ocId
 
-    let notificationCenterReloadMediaPage                       = "reloadMediaPage"
-    let notificationCenterPlayMedia                             = "playMedia"
-    let notificationCenterPauseMedia                            = "pauseMedia"
-
     let notificationCenterDismissScanDocument                   = "dismissScanDocument"
     let notificationCenterDismissUploadAssets                   = "dismissUploadAssets"
 

+ 3 - 20
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -62,7 +62,7 @@ class NCPlayer: NSObject {
     deinit {
 
         print("deinit NCPlayer with ocId \(metadata.ocId)")
-        closeAVPlayer()
+        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
     }
 
     func openAVPlayer(url: URL) {
@@ -99,21 +99,6 @@ class NCPlayer: NSObject {
         }
 
         NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
-
-        NotificationCenter.default.addObserver(self, selector: #selector(playerPause), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPauseMedia), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(playerPlay), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPlayMedia), object: nil)
-    }
-
-    func closeAVPlayer() {
-
-        playerStop()
-
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
-
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPauseMedia), object: nil)
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPlayMedia), object: nil)
     }
 
     // MARK: - UIGestureRecognizerDelegate
@@ -132,8 +117,6 @@ class NCPlayer: NSObject {
         }
     }
 
-    @objc func applicationDidBecomeActive(_ notification: NSNotification) { }
-
     // MARK: -
 
     func isPlay() -> Bool {
@@ -141,7 +124,7 @@ class NCPlayer: NSObject {
         return player?.isPlaying ?? false
     }
 
-    @objc func playerPlay() {
+    func playerPlay() {
 
         playerToolBar?.playbackSliderEvent = .began
         player?.play()
@@ -164,7 +147,7 @@ class NCPlayer: NSObject {
         playerToolBar?.playButtonPlay()
     }
 
-    @objc func playerPause(withSnapshot: Bool = true) {
+    @objc func playerPause() {
 
         savePosition()
         player?.pause()

+ 3 - 12
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -109,8 +109,6 @@ class NCViewerMediaPage: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(hidePlayerToolBar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterHidePlayerToolBar), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(showPlayerToolBar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterShowPlayerToolBar), object: nil)
 
-        NotificationCenter.default.addObserver(self, selector: #selector(reloadMediaPage(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadMediaPage), object: nil)
-
         NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
     }
 
@@ -129,8 +127,6 @@ class NCViewerMediaPage: UIViewController {
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterHidePlayerToolBar), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterShowPlayerToolBar), object: nil)
 
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadMediaPage), object: nil)
-
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
     }
 
@@ -245,7 +241,7 @@ class NCViewerMediaPage: UIViewController {
            let ncplayer = currentViewController.ncplayer {
             let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
             if ncplayer.isPlay() {
-                ncplayer.playerPause(withSnapshot: false)
+                ncplayer.playerPause()
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                     ncplayer.openAVPlayer(url: url)
                     ncplayer.playerPlay()
@@ -375,12 +371,7 @@ class NCViewerMediaPage: UIViewController {
             }
         }
     }
-    
-    @objc func reloadMediaPage(_ notification: NSNotification) {
-        
-        self.reloadCurrentPage()
-    }
-    
+
     @objc func applicationDidBecomeActive(_ notification: NSNotification) {
 
         progressView.progress = 0
@@ -551,7 +542,7 @@ extension NCViewerMediaPage: UIPageViewControllerDelegate, UIPageViewControllerD
         if completed && nextIndex != nil {
             previousViewControllers.forEach { viewController in
                 let viewerMedia = viewController as! NCViewerMedia
-                viewerMedia.ncplayer?.closeAVPlayer()
+                viewerMedia.ncplayer?.playerPause()
             }
             currentIndex = nextIndex!
         }