rDrama/files/templates/event/music.html

25 lines
624 B
HTML
Raw Normal View History

2022-12-19 02:47:53 +00:00
{% if not (v and v.poor) and (not g.event_v or g.event_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>
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 %}