2022-01-13 04:52:14 +00:00
|
|
|
<template>
|
2023-06-13 12:06:53 +00:00
|
|
|
<!-- desktop view -->
|
2023-08-13 17:31:57 +00:00
|
|
|
<div v-if="!mobileLayout" class="max-h-75vh max-w-35vw min-h-64 flex-col overflow-y-scroll lt-lg:hidden">
|
2023-06-13 12:06:53 +00:00
|
|
|
<h2 class="mb-2 bg-gray-500/50 p-2" aria-label="chapters" title="chapters">
|
|
|
|
{{ $t("video.chapters") }} ({{ chapters.length }})
|
|
|
|
</h2>
|
|
|
|
<div
|
|
|
|
v-for="(chapter, index) in chapters"
|
2023-07-27 11:46:05 +00:00
|
|
|
:key="chapter.start"
|
2023-06-13 12:06:53 +00:00
|
|
|
class="chapter-vertical"
|
|
|
|
:class="{ 'bg-red-500/50': isCurrentChapter(index) }"
|
2023-07-27 11:46:05 +00:00
|
|
|
@click="$emit('seek', chapter.start)"
|
2023-06-13 12:06:53 +00:00
|
|
|
>
|
|
|
|
<div class="flex">
|
2023-08-13 17:31:57 +00:00
|
|
|
<span class="mr-2 mt-5 text-current" v-text="index + 1" />
|
2023-06-13 12:06:53 +00:00
|
|
|
<img class="shrink-0" :src="chapter.image" :alt="chapter.title" />
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="m-2 flex flex-col">
|
2023-06-13 12:06:53 +00:00
|
|
|
<span class="text-sm" :title="chapter.title" v-text="chapter.title" />
|
2023-12-19 15:44:16 +00:00
|
|
|
<span class="text-sm text-blue-500 font-bold" v-text="timeFormat(chapter.start)" />
|
2023-06-13 12:06:53 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- mobile vertical view -->
|
2023-06-10 08:47:41 +00:00
|
|
|
<div
|
2023-06-13 12:06:53 +00:00
|
|
|
v-if="mobileLayout && getPreferenceString('mobileChapterLayout') == 'Vertical'"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="max-h-64 flex flex-col overflow-y-scroll"
|
2023-06-10 08:47:41 +00:00
|
|
|
>
|
2022-06-29 11:06:22 +00:00
|
|
|
<h2 class="mb-2 bg-gray-500/50 p-2" aria-label="chapters" title="chapters">
|
|
|
|
{{ $t("video.chapters") }} ({{ chapters.length }})
|
|
|
|
</h2>
|
2022-06-24 01:04:01 +00:00
|
|
|
<div
|
2022-06-29 11:06:22 +00:00
|
|
|
v-for="(chapter, index) in chapters"
|
2023-07-27 11:46:05 +00:00
|
|
|
:key="chapter.start"
|
2022-06-24 01:04:01 +00:00
|
|
|
class="chapter-vertical"
|
2022-07-25 12:20:42 +00:00
|
|
|
:class="{ 'bg-red-500/50': isCurrentChapter(index) }"
|
2023-07-27 11:46:05 +00:00
|
|
|
@click="$emit('seek', chapter.start)"
|
2022-06-24 01:04:01 +00:00
|
|
|
>
|
|
|
|
<div class="flex">
|
2023-08-13 17:31:57 +00:00
|
|
|
<span class="mr-2 mt-5 text-current" v-text="index + 1" />
|
2022-11-28 15:29:09 +00:00
|
|
|
<img class="shrink-0" :src="chapter.image" :alt="chapter.title" />
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="m-2 flex flex-col">
|
2022-07-03 09:53:09 +00:00
|
|
|
<span class="text-sm" :title="chapter.title" v-text="chapter.title" />
|
2023-12-19 15:44:16 +00:00
|
|
|
<span class="text-sm text-blue-500 font-bold" v-text="timeFormat(chapter.start)" />
|
2022-06-24 01:04:01 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-13 12:06:53 +00:00
|
|
|
<!-- mobile Horizontal view -->
|
|
|
|
<div v-if="getPreferenceString('mobileChapterLayout') == 'Horizontal' && mobileLayout" class="flex overflow-x-auto">
|
2022-07-19 12:41:42 +00:00
|
|
|
<div
|
2022-07-22 18:54:52 +00:00
|
|
|
v-for="(chapter, index) in chapters"
|
2023-07-27 11:46:05 +00:00
|
|
|
:key="chapter.start"
|
2022-07-25 12:20:42 +00:00
|
|
|
class="chapter"
|
|
|
|
:class="{ 'bg-red-500/50': isCurrentChapter(index) }"
|
2023-07-27 11:46:05 +00:00
|
|
|
@click="$emit('seek', chapter.start)"
|
2022-07-19 12:41:42 +00:00
|
|
|
>
|
2022-06-24 22:28:06 +00:00
|
|
|
<img :src="chapter.image" :alt="chapter.title" />
|
2022-06-17 05:06:05 +00:00
|
|
|
<div class="m-1 flex">
|
|
|
|
<span class="text-truncate text-sm" :title="chapter.title" v-text="chapter.title" />
|
2023-12-19 15:44:16 +00:00
|
|
|
<span class="px-1 text-sm text-blue-500 font-bold" v-text="timeFormat(chapter.start)" />
|
2022-06-17 05:06:05 +00:00
|
|
|
</div>
|
2022-01-13 04:52:14 +00:00
|
|
|
</div>
|
2023-06-13 12:06:53 +00:00
|
|
|
</div>
|
2022-01-13 04:52:14 +00:00
|
|
|
</template>
|
|
|
|
|
2023-07-27 11:46:05 +00:00
|
|
|
<script setup>
|
|
|
|
const props = defineProps({
|
|
|
|
chapters: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null,
|
|
|
|
},
|
|
|
|
mobileLayout: {
|
|
|
|
type: Boolean,
|
|
|
|
default: () => true,
|
|
|
|
},
|
|
|
|
playerPosition: {
|
|
|
|
type: Number,
|
|
|
|
default: () => 0,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const isCurrentChapter = index => {
|
|
|
|
return (
|
|
|
|
props.playerPosition >= props.chapters[index].start &&
|
|
|
|
props.playerPosition < (props.chapters[index + 1]?.start ?? Infinity)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
defineEmits(["seek"]);
|
|
|
|
</script>
|
|
|
|
|
2022-01-26 04:39:36 +00:00
|
|
|
<style>
|
2022-06-17 05:06:05 +00:00
|
|
|
::-webkit-scrollbar {
|
|
|
|
height: 5px;
|
|
|
|
}
|
2022-01-26 04:39:36 +00:00
|
|
|
.chapter {
|
2022-06-24 22:28:06 +00:00
|
|
|
@apply cursor-pointer self-center p-2.5;
|
2022-08-17 13:34:57 +00:00
|
|
|
}
|
|
|
|
.chapter img {
|
|
|
|
@apply w-full h-full;
|
2022-06-17 05:06:05 +00:00
|
|
|
}
|
2022-06-24 01:04:01 +00:00
|
|
|
.chapter-vertical {
|
2022-06-24 22:28:06 +00:00
|
|
|
@apply cursor-pointer self-center p-2.5;
|
2022-06-24 01:04:01 +00:00
|
|
|
}
|
2022-08-17 13:34:57 +00:00
|
|
|
.chapter-vertical img {
|
|
|
|
@apply w-3/10 h-3/10;
|
|
|
|
}
|
|
|
|
|
2022-06-24 01:04:01 +00:00
|
|
|
.chapter-vertical:hover {
|
|
|
|
@apply bg-gray-500;
|
|
|
|
}
|
2022-06-17 05:06:05 +00:00
|
|
|
.text-truncate {
|
2022-06-24 22:28:06 +00:00
|
|
|
@apply truncate overflow-hidden inline-block w-10em;
|
2022-01-26 04:39:36 +00:00
|
|
|
}
|
|
|
|
</style>
|