2022-06-01 03:13:46 +02:00
|
|
|
<template>
|
2024-04-04 01:41:41 +02:00
|
|
|
<div class="flex items-center pt-4 pb-2 lg:pt-0 lg:pb-2">
|
2022-06-01 03:13:46 +02:00
|
|
|
<div class="flex-grow" />
|
|
|
|
<template v-if="!loading">
|
2024-04-04 01:41:41 +02:00
|
|
|
<ui-tooltip direction="top" :text="$strings.ButtonPreviousChapter" class="mr-4 lg:mr-8">
|
2024-04-03 01:05:44 +02:00
|
|
|
<button :aria-label="$strings.ButtonPreviousChapter" class="text-gray-300" @mousedown.prevent @mouseup.prevent @click.stop="prevChapter">
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-2xl sm:text-3xl">first_page</span>
|
2024-04-03 01:05:44 +02:00
|
|
|
</button>
|
|
|
|
</ui-tooltip>
|
2024-07-13 00:52:48 +02:00
|
|
|
<ui-tooltip direction="top" :text="jumpBackwardText">
|
|
|
|
<button :aria-label="jumpForwardText" class="text-gray-300" @mousedown.prevent @mouseup.prevent @click.stop="jumpBackward">
|
|
|
|
<span class="material-symbols text-2xl sm:text-3xl">replay</span>
|
2024-04-03 01:05:44 +02:00
|
|
|
</button>
|
|
|
|
</ui-tooltip>
|
2024-04-04 01:41:41 +02:00
|
|
|
<button :aria-label="paused ? $strings.ButtonPlay : $strings.ButtonPause" class="p-2 shadow-sm bg-accent flex items-center justify-center rounded-full text-primary mx-4 lg:mx-8" :class="seekLoading ? 'animate-spin' : ''" @mousedown.prevent @mouseup.prevent @click.stop="playPause">
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols fill text-2xl">{{ seekLoading ? 'autorenew' : paused ? 'play_arrow' : 'pause' }}</span>
|
2024-02-15 01:28:19 +01:00
|
|
|
</button>
|
2024-07-13 00:52:48 +02:00
|
|
|
<ui-tooltip direction="top" :text="jumpForwardText">
|
|
|
|
<button :aria-label="jumpForwardText" class="text-gray-300" @mousedown.prevent @mouseup.prevent @click.stop="jumpForward">
|
|
|
|
<span class="material-symbols text-2xl sm:text-3xl">forward_media</span>
|
2024-04-03 01:05:44 +02:00
|
|
|
</button>
|
|
|
|
</ui-tooltip>
|
2024-04-04 01:41:41 +02:00
|
|
|
<ui-tooltip direction="top" :text="$strings.ButtonNextChapter" class="ml-4 lg:ml-8">
|
2024-04-03 01:05:44 +02:00
|
|
|
<button :aria-label="$strings.ButtonNextChapter" :disabled="!hasNextChapter" :class="hasNextChapter ? 'text-gray-300' : 'text-gray-500'" @mousedown.prevent @mouseup.prevent @click.stop="nextChapter">
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-2xl sm:text-3xl">last_page</span>
|
2024-04-03 01:05:44 +02:00
|
|
|
</button>
|
|
|
|
</ui-tooltip>
|
2022-06-19 17:04:15 +02:00
|
|
|
<controls-playback-speed-control v-model="playbackRateInput" @input="playbackRateUpdated" @change="playbackRateChanged" />
|
2022-06-01 03:13:46 +02:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<div class="cursor-pointer p-2 shadow-sm bg-accent flex items-center justify-center rounded-full text-primary mx-8 animate-spin">
|
2024-07-16 00:38:13 +02:00
|
|
|
<span class="material-symbols text-2xl">autorenew</span>
|
2022-06-01 03:13:46 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div class="flex-grow" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
loading: Boolean,
|
|
|
|
seekLoading: Boolean,
|
|
|
|
playbackRate: Number,
|
2022-06-04 19:07:38 +02:00
|
|
|
paused: Boolean,
|
|
|
|
hasNextChapter: Boolean
|
2022-06-01 03:13:46 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
2022-06-19 17:04:15 +02:00
|
|
|
computed: {
|
|
|
|
playbackRateInput: {
|
|
|
|
get() {
|
|
|
|
return this.playbackRate
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('update:playbackRate', val)
|
|
|
|
}
|
2024-07-13 00:52:48 +02:00
|
|
|
},
|
|
|
|
jumpForwardText() {
|
|
|
|
return this.getJumpText('jumpForwardAmount', this.$strings.ButtonJumpForward)
|
|
|
|
},
|
|
|
|
jumpBackwardText() {
|
|
|
|
return this.getJumpText('jumpBackwardAmount', this.$strings.ButtonJumpBackward)
|
2022-06-19 17:04:15 +02:00
|
|
|
}
|
|
|
|
},
|
2022-06-01 03:13:46 +02:00
|
|
|
methods: {
|
|
|
|
playPause() {
|
|
|
|
this.$emit('playPause')
|
|
|
|
},
|
2022-06-04 19:07:38 +02:00
|
|
|
prevChapter() {
|
|
|
|
this.$emit('prevChapter')
|
|
|
|
},
|
|
|
|
nextChapter() {
|
|
|
|
if (!this.hasNextChapter) return
|
|
|
|
this.$emit('nextChapter')
|
2022-06-01 03:13:46 +02:00
|
|
|
},
|
|
|
|
jumpBackward() {
|
|
|
|
this.$emit('jumpBackward')
|
|
|
|
},
|
|
|
|
jumpForward() {
|
|
|
|
this.$emit('jumpForward')
|
|
|
|
},
|
|
|
|
playbackRateUpdated(playbackRate) {
|
|
|
|
this.$emit('setPlaybackRate', playbackRate)
|
|
|
|
},
|
|
|
|
playbackRateChanged(playbackRate) {
|
|
|
|
this.$emit('setPlaybackRate', playbackRate)
|
|
|
|
this.$store.dispatch('user/updateUserSettings', { playbackRate }).catch((err) => {
|
|
|
|
console.error('Failed to update settings', err)
|
|
|
|
})
|
2024-07-13 00:52:48 +02:00
|
|
|
},
|
|
|
|
getJumpText(setting, prefix) {
|
|
|
|
const amount = this.$store.getters['user/getUserSetting'](setting)
|
|
|
|
if (!amount) return prefix
|
|
|
|
|
|
|
|
let formattedTime = ''
|
|
|
|
if (amount <= 60) {
|
2024-07-14 20:56:48 +02:00
|
|
|
formattedTime = this.$getString('LabelTimeDurationXSeconds', [amount])
|
2024-07-13 00:52:48 +02:00
|
|
|
} else {
|
|
|
|
const minutes = Math.floor(amount / 60)
|
2024-07-14 20:56:48 +02:00
|
|
|
formattedTime = this.$getString('LabelTimeDurationXMinutes', [minutes])
|
2024-07-13 00:52:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return `${prefix} - ${formattedTime}`
|
2022-06-01 03:13:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
2024-07-13 00:52:48 +02:00
|
|
|
</script>
|