mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-28 13:58:23 +02:00
Merge pull request #1016 from KaiStarkk/hotfix-pr-1005
[Fix] Prevent crash from force unwrapping nil value in PR-1005
This commit is contained in:
commit
56bc569d4a
1 changed files with 12 additions and 9 deletions
|
@ -583,30 +583,33 @@ 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
|
||||||
if (self!.isPlaying()) {
|
guard let strongSelf = self else { return .commandFailed }
|
||||||
self?.pause()
|
if strongSelf.isPlaying() {
|
||||||
|
strongSelf.pause()
|
||||||
} else {
|
} else {
|
||||||
self?.play(allowSeekBack: true)
|
strongSelf.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
|
||||||
if (self!.isPlaying()) {
|
guard let strongSelf = self else { return .commandFailed }
|
||||||
self?.pause()
|
if strongSelf.isPlaying() {
|
||||||
|
strongSelf.pause()
|
||||||
} else {
|
} else {
|
||||||
self?.play(allowSeekBack: true)
|
strongSelf.play(allowSeekBack: true)
|
||||||
}
|
}
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
commandCenter.togglePlayPauseCommand.isEnabled = true
|
commandCenter.togglePlayPauseCommand.isEnabled = true
|
||||||
commandCenter.togglePlayPauseCommand.addTarget { [weak self] event in
|
commandCenter.togglePlayPauseCommand.addTarget { [weak self] event in
|
||||||
if (self!.isPlaying()) {
|
guard let strongSelf = self else { return .commandFailed }
|
||||||
self?.pause()
|
if strongSelf.isPlaying() {
|
||||||
|
strongSelf.pause()
|
||||||
} else {
|
} else {
|
||||||
self?.play(allowSeekBack: true)
|
strongSelf.play(allowSeekBack: true)
|
||||||
}
|
}
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue