markury commited on
Commit
44b2ffe
·
1 Parent(s): 89118b9

Fix duration display: handle Infinity from base64 audio data URL

Browse files
Files changed (1) hide show
  1. 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 || estimatedDuration; }
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');