seek to good position
All checks were successful
repod / nextcloud (push) Successful in 1m0s
repod / nodejs (push) Successful in 1m27s

This commit is contained in:
Michel Roux 2023-08-28 18:18:25 +02:00
parent d14ee8aee8
commit 157682cd84
5 changed files with 29 additions and 21 deletions

View File

@ -5,7 +5,7 @@
preload preload
:src="episode.episodeUrl" :src="episode.episodeUrl"
@durationchange="duration = audio.duration" @durationchange="duration = audio.duration"
@loadeddata="loading = false" @loadeddata="loadeddata"
@pause="pause" @pause="pause"
@play="paused = false" @play="paused = false"
@seeked="currentTime = audio.currentTime" @seeked="currentTime = audio.currentTime"
@ -17,7 +17,7 @@
:duration="duration" /> :duration="duration" />
<div v-if="!loading" class="player"> <div v-if="!loading" class="player">
<img :src="episode.episodeImage"> <img :src="episode.episodeImage">
<Infos /> <Infos :podcast-url="podcastUrl" />
<Controls :paused="paused" /> <Controls :paused="paused" />
<Timer class="timer" <Timer class="timer"
:current-time="currentTime" :current-time="currentTime"
@ -49,18 +49,13 @@ export default {
Timer, Timer,
Volume, Volume,
}, },
props: {
podcastUrl: {
type: String,
required: true,
},
},
data() { data() {
return { return {
currentTime: 0, currentTime: 0,
duration: 0, duration: 0,
loading: true, loading: true,
paused: false, paused: false,
podcastUrl: atob(this.$route.params.url),
volume: 1, volume: 1,
} }
}, },
@ -73,6 +68,13 @@ export default {
}, },
}, },
methods: { methods: {
loadeddata() {
this.loading = false
if (this.episode.episodeAction) {
this.audio.currentTime = this.episode.episodeAction.position
}
},
pause() { pause() {
this.paused = true this.paused = true
this.track() this.track()
@ -85,9 +87,9 @@ export default {
guid: this.episode.episodeGuid, guid: this.episode.episodeGuid,
action: 'play', action: 'play',
timestamp: formatEpisodeTimestamp(new Date()), timestamp: formatEpisodeTimestamp(new Date()),
started: this.episode.episodeAction ? this.episode.episodeAction.started : 0, started: Math.round(this.episode.episodeAction ? this.episode.episodeAction.started : 0),
position: this.currentTime, position: Math.round(this.currentTime),
total: this.duration, total: Math.round(this.duration),
}]) }])
} catch (e) { } catch (e) {
console.error(e) console.error(e)
@ -117,7 +119,7 @@ export default {
} }
.timer { .timer {
width: 25%; width: 30%;
} }
.volume { .volume {

View File

@ -3,7 +3,7 @@
<a :href="episode.episodeLink" target="_blank"> <a :href="episode.episodeLink" target="_blank">
<strong>{{ episode.episodeName }}</strong> <strong>{{ episode.episodeName }}</strong>
</a> </a>
<router-link v-if="$route.params.url" :to="$route.params.url"> <router-link :to="podcastUrl">
<i>{{ episode.podcastName }}</i> <i>{{ episode.podcastName }}</i>
</router-link> </router-link>
</div> </div>
@ -12,6 +12,12 @@
<script> <script>
export default { export default {
name: 'Infos', name: 'Infos',
props: {
podcastUrl: {
type: String,
required: true,
},
},
computed: { computed: {
episode() { episode() {
return this.$store.state.player.episode return this.$store.state.player.episode
@ -25,6 +31,6 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
width: 45%; width: 40%;
} }
</style> </style>

View File

@ -1,5 +1,5 @@
<template> <template>
<div @click="(event) => audio.fastSeek(event.x * duration / event.target.offsetWidth)"> <div @click="(event) => audio.currentTime = event.x * duration / event.target.offsetWidth">
<NcProgressBar size="medium" :value="currentTime * 100 / duration" /> <NcProgressBar size="medium" :value="currentTime * 100 / duration" />
</div> </div>
</template> </template>

View File

@ -77,7 +77,7 @@ export default {
input { input {
transform: rotate(270deg); transform: rotate(270deg);
width: 60%; width: 4rem;
} }
.pointer { .pointer {

View File

@ -40,11 +40,11 @@ export const formatTimer = (date) => {
export const formatEpisodeTimestamp = (date) => { export const formatEpisodeTimestamp = (date) => {
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth().padStart(2, '0') const month = date.getMonth().toString().padStart(2, '0')
const day = date.getDate().padStart(2, '0') const day = date.getDate().toString().padStart(2, '0')
const hours = date.getHours().padStart(2, '0') const hours = date.getHours().toString().padStart(2, '0')
const mins = date.getMinutes().padStart(2, '0') const mins = date.getMinutes().toString().padStart(2, '0')
const secs = date.getSeconds().padStart(2, '0') const secs = date.getSeconds().toString().padStart(2, '0')
return `${year}-${month}-${day}T${hours}:${mins}:${secs}` return `${year}-${month}-${day}T${hours}:${mins}:${secs}`
} }