mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-13 22:00:28 +05:30
Merge pull request #1214 from kskarthik/master
chapters: highlight current playing chapter
This commit is contained in:
commit
70ab40f2cf
@ -9,6 +9,11 @@
|
|||||||
v-for="(chapter, index) in chapters"
|
v-for="(chapter, index) in chapters"
|
||||||
@click="$emit('seek', chapter.start)"
|
@click="$emit('seek', chapter.start)"
|
||||||
class="chapter-vertical"
|
class="chapter-vertical"
|
||||||
|
:class="
|
||||||
|
playerPosition >= chapter.start && playerPosition < chapters[index + 1].start
|
||||||
|
? 'chapter-vertical bg-red-500/50'
|
||||||
|
: 'chapter-vertical'
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="mt-5 mr-2 text-current" v-text="index + 1" />
|
<span class="mt-5 mr-2 text-current" v-text="index + 1" />
|
||||||
@ -22,7 +27,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- mobile view -->
|
<!-- mobile view -->
|
||||||
<div v-else class="flex overflow-x-auto">
|
<div v-else class="flex overflow-x-auto">
|
||||||
<div :key="chapter.start" v-for="chapter in chapters" @click="$emit('seek', chapter.start)" class="chapter">
|
<div
|
||||||
|
:key="chapter.start"
|
||||||
|
v-for="(chapter, index) in chapters"
|
||||||
|
@click="$emit('seek', chapter.start)"
|
||||||
|
:class="
|
||||||
|
playerPosition >= chapter.start && playerPosition < chapters[index + 1].start
|
||||||
|
? 'chapter bg-red-500/50'
|
||||||
|
: 'chapter'
|
||||||
|
"
|
||||||
|
>
|
||||||
<img :src="chapter.image" :alt="chapter.title" />
|
<img :src="chapter.image" :alt="chapter.title" />
|
||||||
<div class="m-1 flex">
|
<div class="m-1 flex">
|
||||||
<span class="text-truncate text-sm" :title="chapter.title" v-text="chapter.title" />
|
<span class="text-truncate text-sm" :title="chapter.title" v-text="chapter.title" />
|
||||||
@ -65,6 +79,10 @@ defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: () => true,
|
default: () => true,
|
||||||
},
|
},
|
||||||
|
playerPosition: {
|
||||||
|
type: Number,
|
||||||
|
default: () => 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defineEmits(["seek"]);
|
defineEmits(["seek"]);
|
||||||
|
@ -42,6 +42,7 @@ export default {
|
|||||||
selectedAutoLoop: Boolean,
|
selectedAutoLoop: Boolean,
|
||||||
isEmbed: Boolean,
|
isEmbed: Boolean,
|
||||||
},
|
},
|
||||||
|
emits: ["timeupdate"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
lastUpdate: new Date().getTime(),
|
lastUpdate: new Date().getTime(),
|
||||||
@ -343,6 +344,7 @@ export default {
|
|||||||
if (noPrevPlayer) {
|
if (noPrevPlayer) {
|
||||||
videoEl.addEventListener("timeupdate", () => {
|
videoEl.addEventListener("timeupdate", () => {
|
||||||
const time = videoEl.currentTime;
|
const time = videoEl.currentTime;
|
||||||
|
this.$emit("timeupdate", time);
|
||||||
this.updateProgressDatabase(time);
|
this.updateProgressDatabase(time);
|
||||||
if (this.sponsors && this.sponsors.segments) {
|
if (this.sponsors && this.sponsors.segments) {
|
||||||
this.sponsors.segments.map(segment => {
|
this.sponsors.segments.map(segment => {
|
||||||
|
@ -25,11 +25,13 @@
|
|||||||
:index="index"
|
:index="index"
|
||||||
:selected-auto-play="selectedAutoPlay"
|
:selected-auto-play="selectedAutoPlay"
|
||||||
:selected-auto-loop="selectedAutoLoop"
|
:selected-auto-loop="selectedAutoLoop"
|
||||||
|
@timeupdate="onTimeUpdate"
|
||||||
/>
|
/>
|
||||||
<ChaptersBar
|
<ChaptersBar
|
||||||
:mobileLayout="isMobile"
|
:mobileLayout="isMobile"
|
||||||
v-if="video?.chapters?.length > 0"
|
v-if="video?.chapters?.length > 0"
|
||||||
:chapters="video.chapters"
|
:chapters="video.chapters"
|
||||||
|
:player-position="currentTime"
|
||||||
@seek="navigate"
|
@seek="navigate"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -242,6 +244,7 @@ export default {
|
|||||||
smallView: smallViewQuery.matches,
|
smallView: smallViewQuery.matches,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
isMobile: true,
|
isMobile: true,
|
||||||
|
currentTime: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -465,6 +468,9 @@ export default {
|
|||||||
navigate(time) {
|
navigate(time) {
|
||||||
this.$refs.videoPlayer.seek(time);
|
this.$refs.videoPlayer.seek(time);
|
||||||
},
|
},
|
||||||
|
onTimeUpdate(time) {
|
||||||
|
this.currentTime = time;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user