WillHbx commited on
Commit
a85aadb
·
2 Parent(s): 75ce6cd7f86255

Merge branch 'main' of https://huggingface.co/spaces/build-small-hackathon/Hackathon-IA-VisualNovel

Browse files
Files changed (1) hide show
  1. frontend/index.html +10 -0
frontend/index.html CHANGED
@@ -558,9 +558,19 @@ function typeOut(el, text){
558
  }, 16);
559
  }
560
 
 
 
 
 
 
 
 
 
 
561
  // --- render a ViewState ---
562
  let lastBg = null;
563
  function render(v){
 
564
  if (v.known_characters?.length) {
565
  knownChars = v.known_characters;
566
  // cache sprite URLs so they survive when chars go off-stage
 
558
  }, 16);
559
  }
560
 
561
+ // --- audio playback ---
562
+ let _currentAudio = null;
563
+ function playAudio(b64) {
564
+ if (_currentAudio) { _currentAudio.pause(); _currentAudio = null; }
565
+ if (!b64) return;
566
+ _currentAudio = new Audio(b64);
567
+ _currentAudio.play().catch(() => {}); // ignore autoplay policy errors silently
568
+ }
569
+
570
  // --- render a ViewState ---
571
  let lastBg = null;
572
  function render(v){
573
+ if (v.audio_b64) playAudio(v.audio_b64);
574
  if (v.known_characters?.length) {
575
  knownChars = v.known_characters;
576
  // cache sprite URLs so they survive when chars go off-stage