Merge pull request #335 from ronaldheft/ios-respect-skip-settings

Fix: Skip preferences not respected for iOS remote control
This commit is contained in:
advplyr 2022-08-27 14:23:25 -05:00 committed by GitHub
commit fb03c8e67f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -548,6 +548,7 @@ class AudioPlayer: NSObject {
UIApplication.shared.beginReceivingRemoteControlEvents()
}
let commandCenter = MPRemoteCommandCenter.shared()
let deviceSettings = Database.shared.getDeviceSettings()
commandCenter.playCommand.isEnabled = true
commandCenter.playCommand.addTarget { [unowned self] event in
@ -561,7 +562,7 @@ class AudioPlayer: NSObject {
}
commandCenter.skipForwardCommand.isEnabled = true
commandCenter.skipForwardCommand.preferredIntervals = [30]
commandCenter.skipForwardCommand.preferredIntervals = [NSNumber(value: deviceSettings.jumpForwardTime)]
commandCenter.skipForwardCommand.addTarget { [unowned self] event in
guard let command = event.command as? MPSkipIntervalCommand else {
return .noSuchContent
@ -571,7 +572,7 @@ class AudioPlayer: NSObject {
return .success
}
commandCenter.skipBackwardCommand.isEnabled = true
commandCenter.skipBackwardCommand.preferredIntervals = [30]
commandCenter.skipBackwardCommand.preferredIntervals = [NSNumber(value: deviceSettings.jumpBackwardsTime)]
commandCenter.skipBackwardCommand.addTarget { [unowned self] event in
guard let command = event.command as? MPSkipIntervalCommand else {
return .noSuchContent