Browse Source

Remote Command Center

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 năm trước cách đây
mục cha
commit
a7bc937c37

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

@@ -273,7 +273,8 @@ class NCPlayer: NSObject {
                 let cgImage = try imageGenerator.copyCGImage(at: time, actualTime: nil)
                 image = UIImage(cgImage: cgImage)
                 // Update Playing Info Center
-                if let image = image {
+                let mediaItemPropertyTitle = MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyTitle] as? String
+                if let image = image, mediaItemPropertyTitle == metadata.fileNameView {
                     MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in
                         return image
                     }

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

@@ -151,7 +151,7 @@ class NCPlayerToolBar: UIView {
         // COMMAND CENTER
         if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
             endableCommandCenter()
-        } 
+        }
         
         updateToolBar(timeSeek: timeSeek)
         
@@ -246,7 +246,6 @@ class NCPlayerToolBar: UIView {
         guard let ncplayer = self.ncplayer else { return }
         
         UIApplication.shared.beginReceivingRemoteControlEvents()
-        MPRemoteCommandCenter.shared().playCommand.isEnabled = true
         var nowPlayingInfo = [String : Any]()
 
         // Add handler for Play Command
@@ -301,10 +300,10 @@ class NCPlayerToolBar: UIView {
         
         UIApplication.shared.endReceivingRemoteControlEvents()
         MPNowPlayingInfoCenter.default().nowPlayingInfo = [:]
-        MPRemoteCommandCenter.shared().playCommand.isEnabled = false
 
         if let playCommand = appDelegate.commandCenterPlayCommand {
             MPRemoteCommandCenter.shared().playCommand.removeTarget(playCommand)
+            appDelegate.commandCenterPlayCommand = nil
         }
         if let pauseCommand = appDelegate.commandCenterPauseCommand {
             MPRemoteCommandCenter.shared().pauseCommand.removeTarget(pauseCommand)