mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Handle case where AVQueuePlayer doesnt update the current item for shorter audio segments
This commit is contained in:
parent
98df7164e5
commit
be941faf39
1 changed files with 8 additions and 0 deletions
|
|
@ -672,6 +672,14 @@
|
|||
case .reset:
|
||||
if let playerItem = player.currentItem as? SpeechPlayerItem {
|
||||
let itemElapsed = playerItem.status == .readyToPlay ? CMTimeGetSeconds(playerItem.currentTime()) : 0
|
||||
if itemElapsed >= CMTimeGetSeconds(playerItem.duration) + 0.5 {
|
||||
// Occasionally AV wont send an event for a new item starting for ~3s, if this
|
||||
// happens we can try to manually update the time
|
||||
if playerItem.speechItem.audioIdx + 1 < (document?.utterances.count ?? 0) {
|
||||
currentAudioIndex = playerItem.speechItem.audioIdx + 1
|
||||
}
|
||||
}
|
||||
|
||||
timeElapsed = durationBefore(playerIndex: playerItem.speechItem.audioIdx) + itemElapsed
|
||||
timeElapsedString = formatTimeInterval(timeElapsed)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue