diff --git a/NUXT/components/Player/index.vue b/NUXT/components/Player/index.vue index a89a237..13962a8 100644 --- a/NUXT/components/Player/index.vue +++ b/NUXT/components/Player/index.vue @@ -237,6 +237,7 @@ v-if="$refs.player" :current-time="$refs.player.currentTime" :duration="$refs.player.duration" + :controls="controls" />
- {{ $vuetube.humanTime(currentTime) }} + {{ humanWatchTime }} / {{ humanDuration }}
@@ -16,10 +16,17 @@ export default { type: Number, required: true, }, + controls: { + type: Boolean, + required: true, + }, }, data() { return { - humanDuration: 0, + humanWatchTime: "0:00", + humanDuration: "0:00", + + runWatchTimeUpdates: null } }, mounted() { @@ -31,6 +38,23 @@ export default { } }, 100); //--- END Only show end duration when 'this.duration' becomes defined ---// + }, + + methods: { + updateWatchTime() { + this.humanWatchTime = this.$vuetube.humanTime(this.currentTime); + } + }, + + watch: { + controls(newVal) { + if (newVal) { // controls are VISIBLE + this.runWatchTimeUpdates = setInterval(this.updateWatchTime, 250); + } else { // Controls are INVISIBLE + clearInterval(this.runWatchTimeUpdates); + } + } } + };