Update templates/base.html
Browse files- templates/base.html +6 -1
templates/base.html
CHANGED
@@ -21,12 +21,17 @@
|
|
21 |
{% block content %}{% endblock %}
|
22 |
</div>
|
23 |
<!-- Background flute music -->
|
24 |
-
<audio id="flute-audio" src="/static/assets/flute.mp3" loop
|
25 |
<script>
|
26 |
document.addEventListener('DOMContentLoaded', () => {
|
27 |
const audio = document.getElementById('flute-audio');
|
|
|
28 |
audio.play().catch(error => {
|
29 |
console.error('Error playing audio:', error);
|
|
|
|
|
|
|
|
|
30 |
});
|
31 |
});
|
32 |
</script>
|
|
|
21 |
{% block content %}{% endblock %}
|
22 |
</div>
|
23 |
<!-- Background flute music -->
|
24 |
+
<audio id="flute-audio" src="/static/assets/flute.mp3" loop></audio>
|
25 |
<script>
|
26 |
document.addEventListener('DOMContentLoaded', () => {
|
27 |
const audio = document.getElementById('flute-audio');
|
28 |
+
// Attempt to play audio, with a fallback for user interaction
|
29 |
audio.play().catch(error => {
|
30 |
console.error('Error playing audio:', error);
|
31 |
+
// Add a click event to play audio on user interaction (due to browser restrictions)
|
32 |
+
document.body.addEventListener('click', () => {
|
33 |
+
audio.play().catch(err => console.error('Error playing audio on click:', err));
|
34 |
+
}, { once: true });
|
35 |
});
|
36 |
});
|
37 |
</script>
|