mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-26 23:47:25 +00:00
Use events and emits for finding currentTime.
This commit is contained in:
parent
f96a7fa86a
commit
25d82169b6
@ -69,24 +69,21 @@
|
||||
@apply truncate overflow-hidden inline-block w-10em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
export default {
|
||||
emits: ["seek"],
|
||||
props: {
|
||||
chapters: Object,
|
||||
mobileLayout: {
|
||||
type: Boolean,
|
||||
default: () => true,
|
||||
},
|
||||
|
||||
<script setup>
|
||||
import { defineProps, defineEmits } from "vue";
|
||||
|
||||
defineProps({
|
||||
chapters: Object,
|
||||
mobileLayout: {
|
||||
type: Boolean,
|
||||
default: () => true,
|
||||
},
|
||||
data() {
|
||||
return { playerPosition: 0 };
|
||||
playerPosition: {
|
||||
type: Number,
|
||||
default: () => 0,
|
||||
},
|
||||
mounted() {
|
||||
// get current video position in regular intervals
|
||||
setInterval(() => {
|
||||
this.playerPosition = document.querySelector("video").currentTime;
|
||||
}, 2000);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
defineEmits(["seek"]);
|
||||
</script>
|
||||
|
@ -42,6 +42,7 @@ export default {
|
||||
selectedAutoLoop: Boolean,
|
||||
isEmbed: Boolean,
|
||||
},
|
||||
emits: ["timeupdate"],
|
||||
data() {
|
||||
return {
|
||||
lastUpdate: new Date().getTime(),
|
||||
@ -343,6 +344,7 @@ export default {
|
||||
if (noPrevPlayer) {
|
||||
videoEl.addEventListener("timeupdate", () => {
|
||||
const time = videoEl.currentTime;
|
||||
this.$emit("timeupdate", time);
|
||||
this.updateProgressDatabase(time);
|
||||
if (this.sponsors && this.sponsors.segments) {
|
||||
this.sponsors.segments.map(segment => {
|
||||
|
@ -25,11 +25,13 @@
|
||||
:index="index"
|
||||
:selected-auto-play="selectedAutoPlay"
|
||||
:selected-auto-loop="selectedAutoLoop"
|
||||
@timeupdate="onTimeUpdate"
|
||||
/>
|
||||
<ChaptersBar
|
||||
:mobileLayout="isMobile"
|
||||
v-if="video?.chapters?.length > 0"
|
||||
:chapters="video.chapters"
|
||||
:player-position="currentTime"
|
||||
@seek="navigate"
|
||||
/>
|
||||
</div>
|
||||
@ -242,6 +244,7 @@ export default {
|
||||
smallView: smallViewQuery.matches,
|
||||
showModal: false,
|
||||
isMobile: true,
|
||||
currentTime: 0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -465,6 +468,9 @@ export default {
|
||||
navigate(time) {
|
||||
this.$refs.videoPlayer.seek(time);
|
||||
},
|
||||
onTimeUpdate(time) {
|
||||
this.currentTime = time;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user