route v1
This commit is contained in:
@@ -136,12 +136,34 @@ export const usePlayerStore = defineStore('player', {
|
||||
if (!isNaN(progression)) {
|
||||
this.progressionLast = progression
|
||||
}
|
||||
// update current track when changing time in compilation
|
||||
const cur = this.currentTrack
|
||||
if (cur && cur.type === 'compilation') {
|
||||
const dataStore = useDataStore()
|
||||
const tracks = dataStore
|
||||
.getTracksByboxId(cur.boxId)
|
||||
.slice()
|
||||
.filter((t) => t.type === 'compilation')
|
||||
.sort((a, b) => (a.start ?? 0) - (b.start ?? 0))
|
||||
|
||||
// auto advance behavior: playlists use 'ended', compilations use time boundary
|
||||
const track = this.currentTrack
|
||||
if (!track) return
|
||||
const dataStore = useDataStore()
|
||||
const t = audio.currentTime
|
||||
if (tracks.length > 0) {
|
||||
const now = audio.currentTime
|
||||
// find the last track whose start <= now (fallback to first track)
|
||||
let found = tracks[0]
|
||||
for (const t of tracks) {
|
||||
const s = t.start ?? 0
|
||||
if (s <= now) {
|
||||
found = t
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (found && found.id !== cur.id) {
|
||||
// only update metadata reference; do not reload audio
|
||||
this.currentTrack = found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user