use audio tags so i can use preload="None" and hopefully help site speed
parent
55f05bf95c
commit
4d999751d1
|
@ -1,6 +1,4 @@
|
|||
const song = document.getElementById('event-song').value;
|
||||
const audio = new Audio(song);
|
||||
audio.loop = true;
|
||||
const audio = document.getElementById('event-song');
|
||||
|
||||
audio.play();
|
||||
document.addEventListener('click', () => {
|
||||
|
|
|
@ -271,6 +271,7 @@ function areyousure(t) {
|
|||
function prepare_to_pause(audio) {
|
||||
for (const e of document.querySelectorAll('video,audio'))
|
||||
{
|
||||
if (e == audio) continue
|
||||
e.addEventListener('play', () => {
|
||||
if (!audio.paused) audio.pause();
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% if not (SITE_NAME == 'WPD' and not v) and (not v or v.event_music) and not (hole and hole.name == 'music') and not (u and u.song) and not (IS_HOMOWEEN() and p and p.award_count("haunt", v)) %}
|
||||
{% set path = "assets/events/" ~ IS_EVENT() ~ "/music" %}
|
||||
{% set song = SITE_FULL ~ "/" ~ path ~ "/" ~ listdir('files/'~path)|random() ~ '?x=45' %}
|
||||
<input hidden id="event-song" value="{{song}}">
|
||||
<audio id="event-song" hidden preload="none" src="{{song}}" loop></audio>
|
||||
<script defer src="{{'events/shared/js/music.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue