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