rDrama/files/templates/event/music.html

25 lines
628 B
HTML

{% if not (v and v.poor) and (not v or v.event_music) and not (sub and sub.name == 'music') %}
{% if not song %}
{% set path = "assets/event/media/music" %}
{% set song = "/" ~ path ~ "/" ~ listdir('files/' ~ path)|random() ~ '?v=45' %}
{% endif %}
<script nonce="{{g.nonce}}">
const audio = new Audio("{{song}}");
audio.loop=true;
function play() {
audio.play();
}
audio.loop=true;
window.addEventListener('load', function() {
audio.play();
window.addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
prepare_to_pause(audio)
});
</script>
{% endif %}