Эх сурвалжийг харах

coding

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 жил өмнө
parent
commit
ab6fe3d3ba

+ 6 - 4
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -86,14 +86,16 @@ class NCPlayer: NSObject {
                 if !(detailView?.isShow() ?? false) {
                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterShowPlayerToolBar, userInfo: ["ocId":metadata.ocId, "enableTimerAutoHide": false])
                 }
-                playerToolBar?.updateToolBar(timeSeek: .zero, commandCenter: true)
+                playerToolBar?.updateToolBar(commandCenter: true)
             }
         }
         
         timeObserver = appDelegate.player?.addPeriodicTimeObserver(forInterval: CMTimeMakeWithSeconds(1, preferredTimescale: 1), queue: .main, using: { (CMTime) in
-            
             if self.appDelegate.player?.currentItem?.status == .readyToPlay {
-                self.playerToolBar?.updateToolBar()
+                if var currentTime = self.appDelegate.player?.currentTime() {
+                    currentTime = currentTime.convertScale(1000, method: .default)
+                    self.playerToolBar?.playbackSlider.value = Float(currentTime.value)
+                }
             }
         })
         
@@ -253,7 +255,7 @@ class NCPlayer: NSObject {
     func videoSeek(time: CMTime) {
         
         appDelegate.player?.seek(to: time)
-        playerToolBar?.updateToolBar(timeSeek: time)
+        playerToolBar?.updateToolBar()
         self.saveTime(time)
     }
     

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

@@ -143,10 +143,10 @@ class NCPlayerToolBar: UIView {
             labelOverallDuration.text = "-" + NCUtility.shared.stringFromTime(durationTime)
         }
         
-        updateToolBar(timeSeek: timeSeek, commandCenter: true)
+        updateToolBar(commandCenter: true)
     }
     
-    public func updateToolBar(timeSeek: CMTime? = nil, commandCenter: Bool = false) {
+    public func updateToolBar(commandCenter: Bool = false) {
         guard let metadata = self.metadata else { return }
         
         var currentTime = appDelegate.player?.currentTime() ?? .zero
@@ -183,13 +183,8 @@ class NCPlayerToolBar: UIView {
         }
         
         // BACK
-        if timeSeek != nil {
-            playbackSlider.value = Float(timeSeek!.value)
-            MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = timeSeek!.seconds
-        } else {
-            playbackSlider.value = Float(currentTime.value)
-            MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime.seconds
-        }
+        playbackSlider.value = Float(currentTime.value)
+        MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime.seconds
         playbackSlider.isEnabled = true
         
         if #available(iOS 13.0, *) {