Merge branch '110-hintergrundmusik' into 'master'

Resolve "Hintergrundmusik?"

Closes #110

See merge request enrichment-2024/qivip!76
This commit is contained in:
nik8
2025-05-17 12:57:58 +00:00
4 changed files with 33 additions and 0 deletions

Binary file not shown.

View File

@@ -73,6 +73,7 @@
{% block extra_js %} {% block extra_js %}
{% include 'play/game/common_scripts.html' %} {% include 'play/game/common_scripts.html' %}
{% include 'play/game/sound.html' %}
<script> <script>
const joinCode = '{{ quiz_game.join_code }}'; const joinCode = '{{ quiz_game.join_code }}';
const hostId = '{{ host_id }}'; const hostId = '{{ host_id }}';

View File

@@ -128,6 +128,9 @@
</script> </script>
{% endif %} {% endif %}
{% include 'play/game/common_scripts.html' %} {% include 'play/game/common_scripts.html' %}
{% if is_host %}
{% include 'play/game/sound.html' %}
{% endif %}
<script> <script>
const joinCode = '{{ quiz_game.join_code }}'; const joinCode = '{{ quiz_game.join_code }}';
const hostId = '{{ host_id }}'; const hostId = '{{ host_id }}';

View File

@@ -0,0 +1,29 @@
{% load static %}
<audio id="bg-music" src="{% static 'mp3/Hintergrundmusik.mp3' %}" autoplay loop ></audio>
<script>
document.addEventListener("DOMContentLoaded", function () {
const audio = document.getElementById("bg-music");
const savedTime = localStorage.getItem("bg-music-time");
if (savedTime) {
audio.addEventListener("loadedmetadata", () => {
audio.currentTime = parseFloat(savedTime);
});
}
document.addEventListener("click", () => {
audio.play().catch(e => console.warn("Autoplay blockiert:", e));
}, { once: true });
setInterval(() => {
if (!audio.paused) {
localStorage.setItem("bg-music-time", audio.currentTime);
}
}, 0);
});
</script>