Spaces:
Running
Running
fix: remove double-decode probe — fixes MP3/WAV on mobile
Browse files- index.html +4 -13
index.html
CHANGED
|
@@ -615,16 +615,14 @@
|
|
| 615 |
if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
| 616 |
for (const file of files) {
|
| 617 |
showLcdMessage('READING: ' + file.name.slice(0, 20));
|
| 618 |
-
let
|
| 619 |
try {
|
| 620 |
-
// Couche 1 :
|
| 621 |
-
|
| 622 |
-
await audioCtx.decodeAudioData(arrayBuffer.slice(0)); // slice pour ne pas consommer le buffer
|
| 623 |
-
arrayBuffer = await file.arrayBuffer(); // re-lire proprement
|
| 624 |
} catch (_) {
|
| 625 |
// Couche 2 : fallback ffmpeg.wasm
|
| 626 |
try {
|
| 627 |
-
|
| 628 |
} catch (err) {
|
| 629 |
console.error('Cannot decode:', file.name, err);
|
| 630 |
showLcdMessage('ERROR: ' + file.name.slice(0, 18));
|
|
@@ -632,13 +630,6 @@
|
|
| 632 |
continue;
|
| 633 |
}
|
| 634 |
}
|
| 635 |
-
let buffer;
|
| 636 |
-
try {
|
| 637 |
-
buffer = await audioCtx.decodeAudioData(arrayBuffer);
|
| 638 |
-
} catch (err) {
|
| 639 |
-
console.error('decodeAudioData failed after transcode:', file.name, err);
|
| 640 |
-
continue;
|
| 641 |
-
}
|
| 642 |
const { artist, title } = parseName(file.name);
|
| 643 |
state.tracks.push({ name: file.name, artist, title, buffer });
|
| 644 |
}
|
|
|
|
| 615 |
if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
| 616 |
for (const file of files) {
|
| 617 |
showLcdMessage('READING: ' + file.name.slice(0, 20));
|
| 618 |
+
let buffer;
|
| 619 |
try {
|
| 620 |
+
// Couche 1 : décodage natif direct (résultat réutilisé, pas de double-décodage)
|
| 621 |
+
buffer = await audioCtx.decodeAudioData(await file.arrayBuffer());
|
|
|
|
|
|
|
| 622 |
} catch (_) {
|
| 623 |
// Couche 2 : fallback ffmpeg.wasm
|
| 624 |
try {
|
| 625 |
+
buffer = await audioCtx.decodeAudioData(await transcodeToArrayBuffer(file));
|
| 626 |
} catch (err) {
|
| 627 |
console.error('Cannot decode:', file.name, err);
|
| 628 |
showLcdMessage('ERROR: ' + file.name.slice(0, 18));
|
|
|
|
| 630 |
continue;
|
| 631 |
}
|
| 632 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
const { artist, title } = parseName(file.name);
|
| 634 |
state.tracks.push({ name: file.name, artist, title, buffer });
|
| 635 |
}
|