2022-05-28 05:16:27 +00:00
|
|
|
<template>
|
2022-06-08 19:24:47 +00:00
|
|
|
<div style="color: #fff; font-size: 0.75rem">
|
2022-08-10 20:14:21 +00:00
|
|
|
{{ humanWatchTime }}
|
2022-08-10 19:41:27 +00:00
|
|
|
<span style="color: #aaa"> / {{ humanDuration }} </span>
|
2022-05-28 05:16:27 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2022-06-07 18:29:57 +00:00
|
|
|
props: {
|
2022-06-08 15:59:43 +00:00
|
|
|
duration: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-08 16:36:32 +00:00
|
|
|
currentTime: {
|
2022-06-08 15:59:43 +00:00
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-08-10 20:14:21 +00:00
|
|
|
controls: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-05-28 05:16:27 +00:00
|
|
|
},
|
2022-08-10 19:41:27 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2022-08-10 20:14:21 +00:00
|
|
|
humanWatchTime: "0:00",
|
|
|
|
humanDuration: "0:00",
|
|
|
|
|
|
|
|
runWatchTimeUpdates: null
|
2022-08-10 19:41:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-08-10 20:05:06 +00:00
|
|
|
//--- Only show end duration when 'this.duration' becomes defined ---//
|
2022-08-10 19:41:27 +00:00
|
|
|
const durationTimer = setInterval(() => {
|
|
|
|
if (this.duration) {
|
2022-08-10 20:05:06 +00:00
|
|
|
this.humanDuration = this.$vuetube.humanTime(this.duration);
|
2022-08-10 19:41:27 +00:00
|
|
|
return clearInterval(durationTimer);
|
|
|
|
}
|
|
|
|
}, 100);
|
2022-08-10 20:05:06 +00:00
|
|
|
//--- END Only show end duration when 'this.duration' becomes defined ---//
|
2022-08-10 20:14:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
updateWatchTime() {
|
|
|
|
this.humanWatchTime = this.$vuetube.humanTime(this.currentTime);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
controls(newVal) {
|
|
|
|
if (newVal) { // controls are VISIBLE
|
2022-08-10 20:25:25 +00:00
|
|
|
this.updateWatchTime(); // Call to immediately update
|
2022-08-10 20:14:21 +00:00
|
|
|
this.runWatchTimeUpdates = setInterval(this.updateWatchTime, 250);
|
|
|
|
} else { // Controls are INVISIBLE
|
|
|
|
clearInterval(this.runWatchTimeUpdates);
|
|
|
|
}
|
|
|
|
}
|
2022-08-10 19:41:27 +00:00
|
|
|
}
|
2022-08-10 20:14:21 +00:00
|
|
|
|
2022-05-28 05:16:27 +00:00
|
|
|
};
|
|
|
|
</script>
|