Fix race conditions on first launch

This commit is contained in:
ronaldheft
2022-08-18 19:31:32 -04:00
parent af835f2c43
commit bf46c46fc0
4 changed files with 22 additions and 4 deletions
+6
View File
@@ -261,6 +261,12 @@ class AudioPlayer: NSObject {
}
public func setPlaybackRate(_ rate: Float, observed: Bool = false) {
// Handle a race condition on first launch
guard self.status != -1 else {
NSLog("Did not set playback rate as player is not initialized")
return
}
if self.audioPlayer.rate != rate {
NSLog("setPlaybakRate rate changed from \(self.audioPlayer.rate) to \(rate)")
self.audioPlayer.rate = rate
+1
View File
@@ -14,4 +14,5 @@ enum PlayerEvents: String {
case sleepEnded = "com.audiobookshelf.app.player.sleep.ended"
case failed = "com.audiobookshelf.app.player.failed"
case localProgress = "com.audiobookshelf.app.player.localProgress"
case playerUserInterfaceReady = "com.audiobookshelf.app.player.playerUserInterfaceReady"
}