repod/src/components/Player/Bar.vue
Michel Roux 42941b24cc
All checks were successful
repod / nextcloud (push) Successful in 51s
repod / nodejs (push) Successful in 1m30s
track on stop
2023-08-28 18:29:26 +02:00

103 lines
1.9 KiB
Vue

<template>
<div v-if="episode" class="footer">
<audio id="audio-player"
autoplay
preload
:src="episode.episodeUrl"
@durationchange="duration = audio.duration"
@loadeddata="loadeddata"
@pause="paused = true"
@play="paused = false"
@seeked="currentTime = audio.currentTime"
@timeupdate="currentTime = audio.currentTime"
@volumechange="volume = audio.volume" />
<NcLoadingIcon v-if="loading" />
<ProgressBar v-if="!loading"
:current-time="currentTime"
:duration="duration" />
<div v-if="!loading" class="player">
<img :src="episode.episodeImage">
<Infos :podcast-url="podcastUrl" />
<Controls :paused="paused" />
<Timer class="timer"
:current-time="currentTime"
:duration="duration" />
<Volume class="volume" :volume="volume" />
</div>
</div>
</template>
<script>
import Controls from './Controls.vue'
import Infos from './Infos.vue'
import { NcLoadingIcon } from '@nextcloud/vue'
import ProgressBar from './ProgressBar.vue'
import Timer from './Timer.vue'
import Volume from './Volume.vue'
export default {
name: 'Bar',
components: {
Controls,
Infos,
NcLoadingIcon,
ProgressBar,
Timer,
Volume,
},
data() {
return {
currentTime: 0,
duration: 0,
loading: true,
paused: false,
volume: 1,
}
},
computed: {
audio() {
return document.getElementById('audio-player')
},
episode() {
return this.$store.state.player.episode
},
},
methods: {
loadeddata() {
this.loading = false
if (this.episode.episodeAction) {
this.audio.currentTime = this.episode.episodeAction.position
}
},
},
}
</script>
<style scoped>
.footer {
background-color: rgba(66, 66, 66, .9);
bottom: 0;
height: 6rem;
right: 0;
position: absolute;
width: 100%;
z-index: 2000;
}
.player {
display: flex;
gap: 1rem;
height: calc(6rem - 6px);
justify-content: space-between;
}
.timer {
width: 30%;
}
.volume {
width: 10%;
}
</style>