mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-09 12:37:16 -06:00
Fix issue where offline playback starts at the incorrect index (#355)
Fixes an issue where offline playback wouldn't start at the correct track and the player wouldn't reflect the currently playing track
This commit is contained in:
@@ -176,18 +176,28 @@ const QueueContextInitailizer = () => {
|
||||
|
||||
setSkipping(true)
|
||||
|
||||
// Get the item at the start index
|
||||
const startingTrack = audioItems[startIndex]
|
||||
|
||||
const availableAudioItems = filterTracksOnNetworkStatus(
|
||||
networkStatus as networkStatusTypes,
|
||||
audioItems,
|
||||
downloadedTracks ?? [],
|
||||
)
|
||||
|
||||
// The start index may have changed due to the filtered out items
|
||||
const filteredStartIndex = availableAudioItems.findIndex(
|
||||
(item) => item.Id === startingTrack.Id,
|
||||
)
|
||||
|
||||
console.debug(
|
||||
`Filtered out ${
|
||||
audioItems.length - availableAudioItems.length
|
||||
} due to network status being ${networkStatus}`,
|
||||
)
|
||||
|
||||
console.debug(`Filtered start index is ${filteredStartIndex}`)
|
||||
|
||||
const queue = availableAudioItems.map((item) =>
|
||||
mapDtoToTrack(api!, sessionId, item, downloadedTracks ?? [], QueuingType.FromSelection),
|
||||
)
|
||||
@@ -196,11 +206,11 @@ const QueueContextInitailizer = () => {
|
||||
|
||||
await TrackPlayer.setQueue(queue)
|
||||
setPlayQueue(queue)
|
||||
await TrackPlayer.skip(startIndex)
|
||||
await TrackPlayer.skip(filteredStartIndex)
|
||||
|
||||
setSkipping(false)
|
||||
|
||||
console.debug(`Queued ${queue.length} tracks, starting at ${startIndex}`)
|
||||
console.debug(`Queued ${queue.length} tracks, starting at ${filteredStartIndex}`)
|
||||
|
||||
await play()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user