Split components
This commit is contained in:
parent
aae108ffc3
commit
351bfd446c
@ -12,82 +12,38 @@
|
||||
@timeupdate="currentTime = audio.currentTime"
|
||||
@volumechange="volume = audio.volume" />
|
||||
<NcLoadingIcon v-if="loading" />
|
||||
<div v-if="!loading"
|
||||
class="pointer"
|
||||
@click="(event) => audio.fastSeek(event.x * duration / event.target.offsetWidth)">
|
||||
<NcProgressBar size="medium" :value="currentTime * 100 / duration" />
|
||||
</div>
|
||||
<ProgressBar v-if="!loading"
|
||||
:current-time="currentTime"
|
||||
:duration="duration" />
|
||||
<div v-if="!loading" class="player">
|
||||
<img :src="episode.episodeImage">
|
||||
<div class="infos">
|
||||
<a :href="episode.episodeLink" target="_blank">
|
||||
<strong>{{ episode.episodeName }}</strong>
|
||||
</a>
|
||||
<router-link :to="$route.params.url">
|
||||
<i>{{ episode.podcastName }}</i>
|
||||
</router-link>
|
||||
</div>
|
||||
<PauseButton v-if="!paused"
|
||||
class="pointer"
|
||||
:size="50"
|
||||
@click="() => audio.pause()" />
|
||||
<PlayButton v-if="paused"
|
||||
class="pointer"
|
||||
:size="50"
|
||||
@click="() => audio.play()" />
|
||||
<StopButton class="pointer"
|
||||
:size="30"
|
||||
@click="stop" />
|
||||
<div class="time">
|
||||
<span class="current">{{ formatTimer(new Date(currentTime*1000)) }}</span>
|
||||
<span class="divider">/</span>
|
||||
<span class="length">{{ formatTimer(new Date(duration*1000)) }}</span>
|
||||
</div>
|
||||
<div class="volume">
|
||||
<VolumeHigh v-if="volume > 0.7"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeLow v-if="volume > 0 && volume <= 0.3"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeMedium v-if="volume > 0.3 && volume <= 0.7"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeMute v-if="volume == 0"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="unmute" />
|
||||
</div>
|
||||
<Infos />
|
||||
<Controls :paused="paused" />
|
||||
<Timer class="timer"
|
||||
:current-time="currentTime"
|
||||
:duration="duration" />
|
||||
<Volume class="volume" :volume="volume" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { NcLoadingIcon, NcProgressBar } from '@nextcloud/vue'
|
||||
import PauseButton from 'vue-material-design-icons/Pause.vue'
|
||||
import PlayButton from 'vue-material-design-icons/Play.vue'
|
||||
import StopButton from 'vue-material-design-icons/Stop.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'
|
||||
import { formatTimer } from '../../utils/time.js'
|
||||
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,
|
||||
NcProgressBar,
|
||||
PauseButton,
|
||||
PlayButton,
|
||||
StopButton,
|
||||
VolumeHigh,
|
||||
VolumeLow,
|
||||
VolumeMedium,
|
||||
VolumeMute,
|
||||
ProgressBar,
|
||||
Timer,
|
||||
Volume,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -96,7 +52,6 @@ export default {
|
||||
loading: true,
|
||||
paused: true,
|
||||
volume: 1,
|
||||
volumeMuted: 0,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -107,19 +62,6 @@ export default {
|
||||
return this.$store.state.player.episode
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatTimer,
|
||||
mute() {
|
||||
this.volumeMuted = this.audio.volume
|
||||
this.audio.volume = 0
|
||||
},
|
||||
stop() {
|
||||
this.$store.commit('player/play', null)
|
||||
},
|
||||
unmute() {
|
||||
this.audio.volume = this.volumeMuted
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -134,13 +76,6 @@ export default {
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.infos {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
.player {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
@ -148,18 +83,7 @@ export default {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.time, .volume {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.time {
|
||||
.timer {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
|
41
src/components/Player/Controls.vue
Normal file
41
src/components/Player/Controls.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<fragment>
|
||||
<PauseButton v-if="!paused"
|
||||
class="pointer"
|
||||
:size="50"
|
||||
@click="() => audio.pause()" />
|
||||
<PlayButton v-if="paused"
|
||||
class="pointer"
|
||||
:size="50"
|
||||
@click="() => audio.play()" />
|
||||
<StopButton class="pointer"
|
||||
:size="30"
|
||||
@click="$store.commit('player/play', null)" />
|
||||
</fragment>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PauseButton from 'vue-material-design-icons/Pause.vue'
|
||||
import PlayButton from 'vue-material-design-icons/Play.vue'
|
||||
import StopButton from 'vue-material-design-icons/Stop.vue'
|
||||
|
||||
export default {
|
||||
name: 'Controls',
|
||||
components: {
|
||||
PauseButton,
|
||||
PlayButton,
|
||||
StopButton,
|
||||
},
|
||||
props: {
|
||||
paused: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
audio() {
|
||||
return document.getElementById('audio-player')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
30
src/components/Player/Infos.vue
Normal file
30
src/components/Player/Infos.vue
Normal file
@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<div>
|
||||
<a :href="episode.episodeLink" target="_blank">
|
||||
<strong>{{ episode.episodeName }}</strong>
|
||||
</a>
|
||||
<router-link :to="$route.params.url">
|
||||
<i>{{ episode.podcastName }}</i>
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Infos',
|
||||
computed: {
|
||||
episode() {
|
||||
return this.$store.state.player.episode
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 45%;
|
||||
}
|
||||
</style>
|
37
src/components/Player/ProgressBar.vue
Normal file
37
src/components/Player/ProgressBar.vue
Normal file
@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div @click="(event) => audio.fastSeek(event.x * duration / event.target.offsetWidth)">
|
||||
<NcProgressBar size="medium" :value="currentTime * 100 / duration" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { NcProgressBar } from '@nextcloud/vue'
|
||||
|
||||
export default {
|
||||
name: 'ProgressBar',
|
||||
components: {
|
||||
NcProgressBar,
|
||||
},
|
||||
props: {
|
||||
currentTime: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
audio() {
|
||||
return document.getElementById('audio-player')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
37
src/components/Player/Timer.vue
Normal file
37
src/components/Player/Timer.vue
Normal file
@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div>
|
||||
<span>{{ formatTimer(new Date(currentTime*1000)) }}</span>
|
||||
<span>/</span>
|
||||
<span>{{ formatTimer(new Date(duration*1000)) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { formatTimer } from '../../utils/time.js'
|
||||
|
||||
export default {
|
||||
name: 'Timer',
|
||||
props: {
|
||||
currentTime: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatTimer,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
75
src/components/Player/Volume.vue
Normal file
75
src/components/Player/Volume.vue
Normal file
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div>
|
||||
<VolumeHigh v-if="volume > 0.7"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeLow v-if="volume > 0 && volume <= 0.3"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeMedium v-if="volume > 0.3 && volume <= 0.7"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="mute" />
|
||||
<VolumeMute v-if="volume == 0"
|
||||
class="pointer"
|
||||
:size="30"
|
||||
@click="unmute" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
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'
|
||||
|
||||
export default {
|
||||
name: 'Volume',
|
||||
components: {
|
||||
VolumeHigh,
|
||||
VolumeLow,
|
||||
VolumeMedium,
|
||||
VolumeMute,
|
||||
},
|
||||
props: {
|
||||
volume: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
volumeMuted: 0,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
audio() {
|
||||
return document.getElementById('audio-player')
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
mute() {
|
||||
this.volumeMuted = this.audio.volume
|
||||
this.audio.volume = 0
|
||||
},
|
||||
unmute() {
|
||||
this.audio.volume = this.volumeMuted
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user