repod/src/components/Player/Bar.vue

116 lines
2.8 KiB
Vue
Raw Normal View History

2023-08-24 20:29:11 +00:00
<template>
2023-08-27 18:01:26 +00:00
<div v-if="episode" class="footer">
<audio id="audio-player"
autoplay
preload
:src="episode.episodeUrl"
@loadeddata="loading = false"
@pause="paused = audio.paused"
@play="paused = audio.paused"
@seeked="currentTime = audio.currentTime"
@volumechange="volume = audio.volume" />
<NcLoadingIcon v-if="loading" />
<div v-if="!loading"
class="progress"
@click="(event) => audio.fastSeek(event.x * audio.duration / event.target.offsetWidth)">
<NcProgressBar size="medium" :value="currentTime * 100 / audio.duration" />
</div>
<div v-if="!loading" class="player">
<img :src="episode.episodeImage">
<div class="infos">
<a :href="episode.episodeLink" target="_blank">
<strong>{{ episode.episodeName }}</strong>
</a>
<a :href="podcastLink" target="_blank">
<i>{{ episode.podcastName }}</i>
</a>
</div>
<Pause v-if="!paused" :size="50" @click="() => audio.pause()" />
<Play v-if="paused" :size="50" @click="() => audio.play()" />
<div class="time">
<span class="current">{{ currentTime }}</span>
<span class="divider">/</span>
<span class="length">{{ audio.duration }}</span>
</div>
<div class="volume">
<VolumeHigh v-if="audio.volume > 0.7" :size="30" />
<VolumeLow v-if="audio.volume > 0 && audio.volume <= 0.3" :size="30" />
<VolumeMedium v-if="audio.volume > 0.3 && audio.volume <= 0.7" :size="30" />
<VolumeMute v-if="audio.volume == 0" :size="30" />
2023-08-27 10:45:19 +00:00
</div>
2023-08-24 21:19:54 +00:00
</div>
2023-08-27 18:01:26 +00:00
</div>
2023-08-24 20:29:11 +00:00
</template>
<script>
2023-08-27 18:01:26 +00:00
import { NcLoadingIcon, NcProgressBar } from '@nextcloud/vue'
2023-08-27 10:45:19 +00:00
import Pause from 'vue-material-design-icons/Pause.vue'
import Play from 'vue-material-design-icons/Play.vue'
import VolumeHigh from 'vue-material-design-icons/VolumeHigh.vue'
import VolumeLow from 'vue-material-design-icons/VolumeLow.vue'
import VolumeMedium from 'vue-material-design-icons/VolumeMedium.vue'
import VolumeMute from 'vue-material-design-icons/VolumeMute.vue'
2023-08-24 20:29:11 +00:00
export default {
name: 'Bar',
2023-08-27 10:45:19 +00:00
components: {
2023-08-27 18:01:26 +00:00
NcLoadingIcon,
2023-08-27 10:45:19 +00:00
NcProgressBar,
Pause,
Play,
VolumeHigh,
VolumeLow,
VolumeMedium,
VolumeMute,
},
2023-08-27 18:01:26 +00:00
data() {
return {
currentTime: 0,
loading: true,
paused: true,
volume: 0,
}
},
2023-08-24 20:29:11 +00:00
computed: {
2023-08-27 10:45:19 +00:00
audio() {
2023-08-27 18:01:26 +00:00
return document.getElementById('audio-player')
2023-08-27 10:45:19 +00:00
},
2023-08-24 21:19:54 +00:00
episode() {
return this.$store.state.player.episode
2023-08-24 20:29:11 +00:00
},
2023-08-27 10:45:19 +00:00
podcastLink() {
return atob(this.$route.params.url)
},
2023-08-24 20:29:11 +00:00
},
}
</script>
<style scoped>
2023-08-24 21:19:54 +00:00
.footer {
2023-08-27 10:45:19 +00:00
background-color: rgba(66, 66, 66, .9);
2023-08-24 21:59:55 +00:00
bottom: 0;
2023-08-27 10:45:19 +00:00
height: 6rem;
2023-08-24 21:59:55 +00:00
right: 0;
2023-08-24 20:29:11 +00:00
position: absolute;
width: 100%;
2023-08-24 21:59:55 +00:00
z-index: 2000;
2023-08-24 20:29:11 +00:00
}
2023-08-27 10:45:19 +00:00
.infos {
display: flex;
flex-direction: column;
justify-content: center;
width: 44%;
}
.player {
display: flex;
gap: 1rem;
height: calc(6rem - 6px);
}
2023-08-27 18:01:26 +00:00
.progress {
cursor: pointer;
}
2023-08-24 20:29:11 +00:00
</style>