mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-05 02:25:45 +02:00
Rebuild track queue while seeking if player does not have a current track.
This commit is contained in:
parent
78d7ba69df
commit
45d3a15c68
1 changed files with 21 additions and 0 deletions
|
@ -424,6 +424,27 @@ class AudioPlayer: NSObject {
|
|||
let indexOfSeek = getItemIndexForTime(time: to)
|
||||
logger.log("SEEK: Seek to index \(indexOfSeek) | Current index \(self.currentTrackIndex)")
|
||||
|
||||
if self.audioPlayer.currentItem == nil {
|
||||
self.currentTrackIndex = indexOfSeek
|
||||
|
||||
try? playbackSession.update {
|
||||
playbackSession.currentTime = to
|
||||
}
|
||||
|
||||
let playerItems = self.allPlayerItems[indexOfSeek..<self.allPlayerItems.count]
|
||||
|
||||
DispatchQueue.runOnMainQueue {
|
||||
self.audioPlayer.removeAllItems()
|
||||
for item in Array(playerItems) {
|
||||
self.audioPlayer.insert(item, after:self.audioPlayer.items().last)
|
||||
}
|
||||
}
|
||||
|
||||
seekInCurrentTrack(to: to, playbackSession: playbackSession)
|
||||
setupQueueItemStatusObserver()
|
||||
return
|
||||
}
|
||||
|
||||
// Reconstruct queue if seeking to a different track
|
||||
if (self.currentTrackIndex != indexOfSeek) {
|
||||
// When we seek to a different track, we need to make sure to seek the old track to 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue