mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-27 13:54:01 +02:00
add: togglePlayPause route
This commit is contained in:
@@ -583,12 +583,31 @@ class AudioPlayer: NSObject {
|
|||||||
|
|
||||||
commandCenter.playCommand.isEnabled = true
|
commandCenter.playCommand.isEnabled = true
|
||||||
commandCenter.playCommand.addTarget { [weak self] event in
|
commandCenter.playCommand.addTarget { [weak self] event in
|
||||||
self?.play(allowSeekBack: true)
|
if (self!.isPlaying()) {
|
||||||
|
self?.pause()
|
||||||
|
} else {
|
||||||
|
self?.play(allowSeekBack: true)
|
||||||
|
}
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
commandCenter.pauseCommand.isEnabled = true
|
commandCenter.pauseCommand.isEnabled = true
|
||||||
commandCenter.pauseCommand.addTarget { [weak self] event in
|
commandCenter.pauseCommand.addTarget { [weak self] event in
|
||||||
self?.pause()
|
if (self!.isPlaying()) {
|
||||||
|
self?.pause()
|
||||||
|
} else {
|
||||||
|
self?.play(allowSeekBack: true)
|
||||||
|
}
|
||||||
|
return .success
|
||||||
|
}
|
||||||
|
|
||||||
|
commandCenter.togglePlayPauseCommand.isEnabled = true
|
||||||
|
commandCenter.togglePlayPauseCommand.addTarget { [weak self] event in
|
||||||
|
if (self!.isPlaying()) {
|
||||||
|
self?.pause()
|
||||||
|
} else {
|
||||||
|
self?.play(allowSeekBack: true)
|
||||||
|
}
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user