diff --git a/.pmomusic_audio/cache.db b/.pmomusic_audio/cache.db
index 627bd1df..55043044 100644
Binary files a/.pmomusic_audio/cache.db and b/.pmomusic_audio/cache.db differ
diff --git a/pmoapp/webapp/src/components/AudioCacheManager.vue b/pmoapp/webapp/src/components/AudioCacheManager.vue
index e6cd108c..4c756b82 100644
--- a/pmoapp/webapp/src/components/AudioCacheManager.vue
+++ b/pmoapp/webapp/src/components/AudioCacheManager.vue
@@ -178,8 +178,20 @@
-
-
+
+
+
+
{{ audioError }}
+
+
@@ -218,6 +230,10 @@ const isConsolidating = ref(false);
const isPurging = ref(false);
const deletingTracks = ref(new Set());
+// Lecteur audio
+const isPlaying = ref(false);
+const audioError = ref("");
+
// --- Computed ---
const totalHits = computed(() => tracks.value.reduce((sum, t) => sum + t.hits, 0));
@@ -305,9 +321,61 @@ async function handleConsolidate() {
}
function playTrack(pk: string) {
+ audioError.value = "";
+ isPlaying.value = true;
+
+ // Attendre que le DOM soit mis à jour (car le lecteur audio est dans un v-if)
+ setTimeout(() => {
+ if (audioPlayer.value) {
+ const url = getTrackUrl(pk);
+ audioPlayer.value.src = url;
+ audioPlayer.value.play().catch((error) => {
+ console.error("Failed to play audio:", error);
+ audioError.value = `Cannot play audio: ${error.message}. Your browser may not support FLAC format.`;
+ isPlaying.value = false;
+ });
+ }
+ }, 100);
+}
+
+function stopTrack() {
if (audioPlayer.value) {
- audioPlayer.value.src = getTrackUrl(pk);
- audioPlayer.value.play();
+ audioPlayer.value.pause();
+ audioPlayer.value.currentTime = 0;
+ audioPlayer.value.src = "";
+ }
+ isPlaying.value = false;
+ audioError.value = "";
+}
+
+function handleAudioEnded() {
+ isPlaying.value = false;
+ audioError.value = "";
+}
+
+function handleAudioError() {
+ const audio = audioPlayer.value;
+ if (audio?.error) {
+ let message = "Audio playback error: ";
+ switch (audio.error.code) {
+ case 1:
+ message += "Loading aborted";
+ break;
+ case 2:
+ message += "Network error";
+ break;
+ case 3:
+ message += "Format not supported";
+ break;
+ case 4:
+ message += "Source not found";
+ break;
+ default:
+ message += "Unknown error";
+ }
+ console.error('Audio player error:', message, 'code:', audio.error.code);
+ audioError.value = message;
+ isPlaying.value = false;
}
}
@@ -330,7 +398,9 @@ function formatDate(dateString: string) {
return d.toLocaleDateString();
}
-onMounted(() => refreshTracks());
+onMounted(() => {
+ refreshTracks();
+});
diff --git a/pmoapp/webapp/vite.config.ts b/pmoapp/webapp/vite.config.ts
index c7e0ac58..540c11ef 100644
--- a/pmoapp/webapp/vite.config.ts
+++ b/pmoapp/webapp/vite.config.ts
@@ -5,4 +5,16 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
base: '/app/', // Base path pour le déploiement
+ server: {
+ proxy: {
+ '/api': {
+ target: 'http://localhost:8080',
+ changeOrigin: true,
+ },
+ '/audio': {
+ target: 'http://localhost:8080',
+ changeOrigin: true,
+ },
+ },
+ },
})