forked from noxious/client
auto start music pre-fix
This commit is contained in:
parent
1afd01bab2
commit
b24e7c1fe3
@ -1,10 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<audio ref="bgm" id="bgm" src="/assets/sound/bgm.mp3" loop autoplay></audio>
|
<audio ref="bgm" id="bgm" src="/assets/music/bgm.mp3" loop autoplay></audio>
|
||||||
<img src="/assets/Leaf_BG_standalone.png" class="bg-img" alt="login bg" />
|
<img src="/assets/Leaf_BG_standalone.png" class="bg-img" alt="login bg" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
|
||||||
|
const bgm = ref('bgm');
|
||||||
|
const bgmStart = () => bgm.value.play();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// check if bgm is playing already and do nothing
|
||||||
|
if (bgm.value.paused) {
|
||||||
|
window.addEventListener('click', () => bgm.value.play())
|
||||||
|
window.addEventListener('keydown', () => bgm.value.play())
|
||||||
|
window.addEventListener('mousemove', () => bgm.value.play())
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user