diff --git a/ios/App/Shared/player/AudioPlayer.swift b/ios/App/Shared/player/AudioPlayer.swift index a2e99634..0ad0e9e6 100644 --- a/ios/App/Shared/player/AudioPlayer.swift +++ b/ios/App/Shared/player/AudioPlayer.swift @@ -584,6 +584,7 @@ class AudioPlayer: NSObject { let jumpBackwardsTime = deviceSettings.jumpBackwardsTime commandCenter.playCommand.isEnabled = true + commandCenter.playCommand.removeTarget(nil) commandCenter.playCommand.addTarget { [weak self] event in guard let strongSelf = self else { return .commandFailed } if strongSelf.isPlaying() { @@ -595,6 +596,7 @@ class AudioPlayer: NSObject { } commandCenter.pauseCommand.isEnabled = true + commandCenter.pauseCommand.removeTarget(nil) commandCenter.pauseCommand.addTarget { [weak self] event in guard let strongSelf = self else { return .commandFailed } if strongSelf.isPlaying() { @@ -606,6 +608,7 @@ class AudioPlayer: NSObject { } commandCenter.togglePlayPauseCommand.isEnabled = true + commandCenter.togglePlayPauseCommand.removeTarget(nil) commandCenter.togglePlayPauseCommand.addTarget { [weak self] event in guard let strongSelf = self else { return .commandFailed } if strongSelf.isPlaying() { @@ -617,6 +620,7 @@ class AudioPlayer: NSObject { } commandCenter.skipForwardCommand.isEnabled = true + commandCenter.skipForwardCommand.removeTarget(nil) commandCenter.skipForwardCommand.preferredIntervals = [NSNumber(value: jumpForwardTime)] commandCenter.skipForwardCommand.addTarget { [weak self] event in guard let command = event.command as? MPSkipIntervalCommand else { @@ -629,6 +633,7 @@ class AudioPlayer: NSObject { return .success } commandCenter.skipBackwardCommand.isEnabled = true + commandCenter.skipBackwardCommand.removeTarget(nil) commandCenter.skipBackwardCommand.preferredIntervals = [NSNumber(value: jumpBackwardsTime)] commandCenter.skipBackwardCommand.addTarget { [weak self] event in guard let command = event.command as? MPSkipIntervalCommand else { @@ -642,6 +647,7 @@ class AudioPlayer: NSObject { } commandCenter.nextTrackCommand.isEnabled = true + commandCenter.nextTrackCommand.removeTarget(nil) commandCenter.nextTrackCommand.addTarget { [weak self] _ in guard let currentTime = self?.getCurrentTime() else { return .commandFailed @@ -650,6 +656,7 @@ class AudioPlayer: NSObject { return .success } commandCenter.previousTrackCommand.isEnabled = true + commandCenter.previousTrackCommand.removeTarget(nil) commandCenter.previousTrackCommand.addTarget { [weak self] _ in guard let currentTime = self?.getCurrentTime() else { return .commandFailed @@ -659,6 +666,7 @@ class AudioPlayer: NSObject { } commandCenter.changePlaybackPositionCommand.isEnabled = deviceSettings.allowSeekingOnMediaControls + commandCenter.changePlaybackPositionCommand.removeTarget(nil) commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in guard let event = event as? MPChangePlaybackPositionCommandEvent else { return .noSuchContent @@ -676,6 +684,7 @@ class AudioPlayer: NSObject { } commandCenter.changePlaybackRateCommand.isEnabled = true + commandCenter.changePlaybackRateCommand.removeTarget(nil) commandCenter.changePlaybackRateCommand.supportedPlaybackRates = [0.5, 0.75, 1.0, 1.25, 1.5, 2] commandCenter.changePlaybackRateCommand.addTarget { [weak self] event in guard let event = event as? MPChangePlaybackRateCommandEvent else {