mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-17 16:21:05 +02:00
Fix player reporting currentTime=0
This commit is contained in:
parent
93cb27d324
commit
a59f3bb957
1 changed files with 9 additions and 5 deletions
|
@ -144,18 +144,22 @@ class AudioPlayer: NSObject {
|
||||||
NSLog("queueStatusObserver: Current Item Ready to play. PlayWhenReady: \(self.playWhenReady)")
|
NSLog("queueStatusObserver: Current Item Ready to play. PlayWhenReady: \(self.playWhenReady)")
|
||||||
self.updateNowPlaying()
|
self.updateNowPlaying()
|
||||||
|
|
||||||
|
// Seek the player before initializing, so a currentTime of 0 does not appear in MediaProgress / session
|
||||||
let firstReady = self.status < 0
|
let firstReady = self.status < 0
|
||||||
self.status = 0
|
if firstReady || self.playWhenReady {
|
||||||
if self.playWhenReady {
|
|
||||||
self.seek(playbackSession.currentTime, from: "queueItemStatusObserver")
|
self.seek(playbackSession.currentTime, from: "queueItemStatusObserver")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark the player as ready
|
||||||
|
self.status = 0
|
||||||
|
|
||||||
|
// Start the player, if requested
|
||||||
|
if self.playWhenReady {
|
||||||
self.playWhenReady = false
|
self.playWhenReady = false
|
||||||
self.play()
|
self.play()
|
||||||
} else if (firstReady) { // Only seek on first readyToPlay
|
|
||||||
self.seek(playbackSession.currentTime, from: "queueItemStatusObserver")
|
|
||||||
}
|
}
|
||||||
} else if (playerItem.status == .failed) {
|
} else if (playerItem.status == .failed) {
|
||||||
NSLog("queueStatusObserver: FAILED \(playerItem.error?.localizedDescription ?? "")")
|
NSLog("queueStatusObserver: FAILED \(playerItem.error?.localizedDescription ?? "")")
|
||||||
|
|
||||||
NotificationCenter.default.post(name: NSNotification.Name(PlayerEvents.failed.rawValue), object: nil)
|
NotificationCenter.default.post(name: NSNotification.Name(PlayerEvents.failed.rawValue), object: nil)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue