2022-01-13 04:52:14 +00:00
|
|
|
<template>
|
2022-06-24 01:04:01 +00:00
|
|
|
<!-- desktop view -->
|
2022-06-24 21:53:45 +00:00
|
|
|
<div v-if="!mobileLayout" class="flex-col overflow-y-scroll max-h-75vh min-h-64 <lg:hidden">
|
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
|
|
|
|
:key="chapter.start"
|
2022-06-29 11:06:22 +00:00
|
|
|
v-for="(chapter, index) in chapters"
|
2022-06-24 01:04:01 +00:00
|
|
|
@click="$emit('seek', chapter.start)"
|
|
|
|
class="chapter-vertical"
|
2022-07-19 12:41:42 +00:00
|
|
|
:class="
|
2022-07-22 18:50:21 +00:00
|
|
|
isCurrentChapter(chapters, index, playerPosition)
|
2022-07-19 12:41:42 +00:00
|
|
|
? 'chapter-vertical bg-red-500/50'
|
|
|
|
: 'chapter-vertical'
|
|
|
|
"
|
2022-06-24 01:04:01 +00:00
|
|
|
>
|
|
|
|
<div class="flex">
|
2022-06-29 11:06:22 +00:00
|
|
|
<span class="mt-5 mr-2 text-current" v-text="index + 1" />
|
2022-06-24 01:04:01 +00:00
|
|
|
<img :src="chapter.image" :alt="chapter.title" />
|
|
|
|
<div class="flex flex-col m-2">
|
2022-07-03 09:53:09 +00:00
|
|
|
<span class="text-sm" :title="chapter.title" v-text="chapter.title" />
|
2022-06-24 01:04:01 +00:00
|
|
|
<span class="text-sm font-bold text-blue-500" v-text="timeFormat(chapter.start)" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- mobile view -->
|
|
|
|
<div v-else class="flex overflow-x-auto">
|
2022-07-19 12:41:42 +00:00
|
|
|
<div
|
|
|
|
:key="chapter.start"
|
2022-07-22 18:54:52 +00:00
|
|
|
v-for="(chapter, index) in chapters"
|
2022-07-19 12:41:42 +00:00
|
|
|
@click="$emit('seek', chapter.start)"
|
2022-07-22 18:50:21 +00:00
|
|
|
:class="isCurrentChapter(chapters, index, playerPosition) ? 'chapter bg-red-500/50' : 'chapter'"
|
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" />
|
2022-06-24 22:28:06 +00:00
|
|
|
<span class="px-1 text-sm font-bold text-blue-500" v-text="timeFormat(chapter.start)" />
|
2022-06-17 05:06:05 +00:00
|
|
|
</div>
|
2022-01-13 04:52:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
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-06-17 05:06:05 +00:00
|
|
|
img {
|
2022-06-24 22:28:06 +00:00
|
|
|
@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
|
|
|
img {
|
2022-06-24 22:28:06 +00:00
|
|
|
@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>
|
2022-07-19 16:29:03 +00:00
|
|
|
|
2022-07-22 18:50:21 +00:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
isCurrentChapter(chapters, index, playerPosition) {
|
2022-07-22 18:52:35 +00:00
|
|
|
if (index + 1 == chapters.length) {
|
|
|
|
if (playerPosition >= chapters[index].start) return true;
|
|
|
|
else return false;
|
|
|
|
} else if (playerPosition >= chapters[index].start && playerPosition < chapters[index + 1].start)
|
|
|
|
return true;
|
2022-07-22 18:50:21 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2022-07-19 16:29:03 +00:00
|
|
|
<script setup>
|
|
|
|
import { defineProps, defineEmits } from "vue";
|
|
|
|
|
|
|
|
defineProps({
|
|
|
|
chapters: Object,
|
|
|
|
mobileLayout: {
|
|
|
|
type: Boolean,
|
|
|
|
default: () => true,
|
2022-07-19 12:41:42 +00:00
|
|
|
},
|
2022-07-19 16:29:03 +00:00
|
|
|
playerPosition: {
|
|
|
|
type: Number,
|
|
|
|
default: () => 0,
|
2022-07-19 12:41:42 +00:00
|
|
|
},
|
2022-07-19 16:29:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
defineEmits(["seek"]);
|
2022-01-13 04:52:14 +00:00
|
|
|
</script>
|