FEAT: side A/B
All checks were successful
Deploy App / build (push) Successful in 14s
Deploy App / deploy (push) Successful in 9s

This commit is contained in:
valere
2025-11-15 21:56:37 +01:00
parent 3424d2d6fc
commit 1b8b998622
49 changed files with 563 additions and 822 deletions

View File

@@ -3,7 +3,6 @@ import { defineStore } from 'pinia'
import type { Track, Box } from '~/../types/types'
import { useDataStore } from '~/store/data'
import { useCardStore } from '~/store/card'
import { useFavoritesStore, FAVORITES_BOX_ID } from '~/store/favorites'
export const usePlayerStore = defineStore('player', {
state: () => ({
@@ -40,18 +39,8 @@ export const usePlayerStore = defineStore('player', {
if (!track) return
const dataStore = useDataStore()
const favoritesStore = useFavoritesStore()
// Vérifier si on est dans la playlist des favoris
if (track.boxId === FAVORITES_BOX_ID) {
const nextTrack = favoritesStore.getNextTrack(track.id)
if (nextTrack) {
await this.playTrack(nextTrack)
return
}
}
// Comportement par défaut pour les playlists standards
else if (track.type === 'playlist') {
if (track.type === 'playlist') {
const next = dataStore.getNextPlaylistTrack(track)
if (next && next.boxId === track.boxId) {
await this.playTrack(next)
@@ -85,16 +74,10 @@ export const usePlayerStore = defineStore('player', {
},
async playTrack(track: Track) {
// Si c'est une piste de la playlist utilisateur, on utilise directement cette piste
if (track.boxId === FAVORITES_BOX_ID) {
this.currentTrack = track
await this.loadAndPlayTrack(track)
} else {
// Pour les autres types de pistes, on utilise la logique existante
this.isCompilationTrack(track)
? await this.playCompilationTrack(track)
: await this.playPlaylistTrack(track)
}
// Pour les autres types de pistes, on utilise la logique existante
this.isCompilationTrack(track)
? await this.playCompilationTrack(track)
: await this.playPlaylistTrack(track)
},
async playCompilationTrack(track: Track) {
@@ -214,7 +197,6 @@ export const usePlayerStore = defineStore('player', {
async togglePlay() {
if (!this.audio) return
try {
if (this.audio.paused) {
await this.audio.play()
@@ -240,11 +222,11 @@ export const usePlayerStore = defineStore('player', {
this.progressionLast = progression
}
// update current track when changing time in compilation
const cur = this.currentTrack
if (cur && cur.type === 'compilation') {
const currentTrack = this.currentTrack
if (currentTrack && currentTrack.type === 'compilation') {
const dataStore = useDataStore()
const tracks = dataStore
.getTracksByboxId(cur.boxId)
.getTracksByboxId(currentTrack.boxId, currentTrack.side)
.slice()
.filter((t) => t.type === 'compilation')
.sort((a, b) => (a.start ?? 0) - (b.start ?? 0))
@@ -261,7 +243,7 @@ export const usePlayerStore = defineStore('player', {
break
}
}
if (nextTrack && nextTrack.id !== cur.id) {
if (nextTrack && nextTrack.id !== currentTrack.id) {
// only update metadata reference; do not reload audio
this.currentTrack = nextTrack