2022-05-11 00:03:41 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full my-2">
|
|
|
|
<div class="w-full bg-primary px-6 py-2 flex items-center cursor-pointer" @click.stop="clickBar">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="pr-4">{{ $strings.HeaderChapters }}</p>
|
2022-05-11 00:03:41 +02:00
|
|
|
<span class="bg-black-400 rounded-xl py-1 px-2 text-sm font-mono">{{ chapters.length }}</span>
|
|
|
|
<div class="flex-grow" />
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-btn v-if="userCanUpdate" small :to="`/audiobook/${libraryItemId}/chapters`" color="primary" class="mr-2">{{ $strings.ButtonEditChapters }}</ui-btn>
|
2022-05-11 00:03:41 +02:00
|
|
|
<div v-if="!keepOpen" class="cursor-pointer h-10 w-10 rounded-full hover:bg-black-400 flex justify-center items-center duration-500" :class="expanded ? 'transform rotate-180' : ''">
|
|
|
|
<span class="material-icons text-4xl">expand_more</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<transition name="slide">
|
|
|
|
<table class="text-sm tracksTable" v-show="expanded || keepOpen">
|
2023-02-11 22:02:56 +01:00
|
|
|
<tr>
|
2022-05-11 00:03:41 +02:00
|
|
|
<th class="text-left w-16"><span class="px-4">Id</span></th>
|
2022-11-08 01:27:17 +01:00
|
|
|
<th class="text-left">{{ $strings.LabelTitle }}</th>
|
|
|
|
<th class="text-center">{{ $strings.LabelStart }}</th>
|
|
|
|
<th class="text-center">{{ $strings.LabelEnd }}</th>
|
2022-05-11 00:03:41 +02:00
|
|
|
</tr>
|
|
|
|
<tr v-for="chapter in chapters" :key="chapter.id">
|
|
|
|
<td class="text-left">
|
|
|
|
<p class="px-4">{{ chapter.id }}</p>
|
|
|
|
</td>
|
2024-03-28 22:56:59 +01:00
|
|
|
<td dir="auto">
|
2022-05-11 00:03:41 +02:00
|
|
|
{{ chapter.title }}
|
|
|
|
</td>
|
2022-07-30 19:25:15 +02:00
|
|
|
<td class="font-mono text-center hover:underline cursor-pointer" @click.stop="goToTimestamp(chapter.start)">
|
2022-05-11 00:03:41 +02:00
|
|
|
{{ $secondsToTimestamp(chapter.start) }}
|
|
|
|
</td>
|
2022-07-30 19:25:15 +02:00
|
|
|
<td class="font-mono text-center hover:underline cursor-pointer" @click.stop="goToTimestamp(chapter.start)">
|
2022-05-11 00:03:41 +02:00
|
|
|
{{ $secondsToTimestamp(chapter.end) }}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
libraryItem: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
},
|
|
|
|
keepOpen: Boolean
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
expanded: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
libraryItemId() {
|
|
|
|
return this.libraryItem.id
|
|
|
|
},
|
|
|
|
media() {
|
|
|
|
return this.libraryItem ? this.libraryItem.media || {} : {}
|
|
|
|
},
|
2022-07-30 19:25:15 +02:00
|
|
|
metadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
2022-05-11 00:03:41 +02:00
|
|
|
chapters() {
|
|
|
|
return this.media.chapters || []
|
|
|
|
},
|
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickBar() {
|
|
|
|
this.expanded = !this.expanded
|
2022-07-30 19:25:15 +02:00
|
|
|
},
|
|
|
|
goToTimestamp(time) {
|
2022-11-12 23:48:35 +01:00
|
|
|
const queueItem = {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
libraryId: this.libraryItem.libraryId,
|
|
|
|
episodeId: null,
|
|
|
|
title: this.metadata.title,
|
|
|
|
subtitle: this.metadata.authors.map((au) => au.name).join(', '),
|
|
|
|
caption: '',
|
|
|
|
duration: this.media.duration || null,
|
|
|
|
coverPath: this.media.coverPath || null
|
|
|
|
}
|
|
|
|
|
2022-07-30 19:25:15 +02:00
|
|
|
if (this.$store.getters['getIsMediaStreaming'](this.libraryItemId)) {
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
episodeId: null,
|
2022-11-12 23:48:35 +01:00
|
|
|
startTime: time,
|
|
|
|
queueItems: [queueItem]
|
2022-07-30 19:25:15 +02:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
const payload = {
|
|
|
|
message: `Start playback for "${this.metadata.title}" at ${this.$secondsToTimestamp(time)}?`,
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
episodeId: null,
|
2022-11-12 23:48:35 +01:00
|
|
|
startTime: time,
|
|
|
|
queueItems: [queueItem]
|
2022-07-30 19:25:15 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
}
|
2022-05-11 00:03:41 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|