Try to play current audio after DOM is loaded

This commit is contained in:
p11 2025-04-27 18:18:58 +02:00
parent 6ade74df7e
commit f63d7d9c1f

View File

@ -408,10 +408,13 @@ fn interactive_script(total_sections: usize, base_path: &str) -> Markup {
toggleText(true);
window.addEventListener('load', () => {{
document.addEventListener('DOMContentLoaded', () => {{
playCurrentAudio();
Array({total_sections}).fill().forEach((_, i) => {{
const audio = new Audio(`{base_path}.${{i}}.mp3`);
audio.preload = 'metadata';
if(i > 0) {{
new Audio(`{base_path}.${{i}}.mp3`).preload = 'metadata';
}}
}});
}});
"#)))