Fix duration display: handle Infinity from base64 audio data URL
Browse files- visualizer.py +1 -1
visualizer.py
CHANGED
|
@@ -135,7 +135,7 @@ TEMPLATE = """<!DOCTYPE html>
|
|
| 135 |
audio.addEventListener('loadedmetadata', () => { totalDuration = audio.duration; });
|
| 136 |
const allNoteSecs = Object.values(DATA.notes).flat().map(n => tickToSec(n.tick + (n.sustain || 0)));
|
| 137 |
const estimatedDuration = allNoteSecs.length ? Math.max(...allNoteSecs) + 5 : 120;
|
| 138 |
-
function getDuration() { return totalDuration
|
| 139 |
|
| 140 |
// --- Controls ---
|
| 141 |
const playBtn = document.getElementById('viz-play');
|
|
|
|
| 135 |
audio.addEventListener('loadedmetadata', () => { totalDuration = audio.duration; });
|
| 136 |
const allNoteSecs = Object.values(DATA.notes).flat().map(n => tickToSec(n.tick + (n.sustain || 0)));
|
| 137 |
const estimatedDuration = allNoteSecs.length ? Math.max(...allNoteSecs) + 5 : 120;
|
| 138 |
+
function getDuration() { return (totalDuration && isFinite(totalDuration)) ? totalDuration : estimatedDuration; }
|
| 139 |
|
| 140 |
// --- Controls ---
|
| 141 |
const playBtn = document.getElementById('viz-play');
|