Files
evilspins/app/components/player.vue
valere f59c496c5d
All checks were successful
Deploy App / build (push) Successful in 2m25s
Deploy App / deploy (push) Successful in 15s
route v1
2025-10-21 00:09:26 +02:00

32 lines
1005 B
Vue

<template>
<div class="fixed left-0 z-50 w-full bg-white transition-all -bottom-20 opacity-0 h-0"
:class="{ 'bottom-0 opacity-100 h-20': playerStore.currentTrack }">
<div class="flex items-center gap-3 p-2">
<img v-if="playerStore.getCurrentCoverUrl" :src="playerStore.getCurrentCoverUrl as string" alt="Current cover"
class="size-16 object-cover object-center rounded" />
<audio ref="audioRef" class="flex-1" controls />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import { usePlayerStore } from '~/store/player'
const playerStore = usePlayerStore()
const audioRef = ref<HTMLAudioElement | null>(null)
onMounted(() => {
if (audioRef.value) {
playerStore.attachAudio(audioRef.value)
audioRef.value.addEventListener("timeupdate", playerStore.updateTime)
}
})
onUnmounted(() => {
if (audioRef.value) {
audioRef.value.removeEventListener("timeupdate", playerStore.updateTime)
}
})
</script>