mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-25 12:45:17 +00:00
perf: ⚡ Human time is calculated a lot less (2/3)
This commit is contained in:
parent
854fbdd514
commit
3392ff1bd7
2 changed files with 27 additions and 2 deletions
|
@ -237,6 +237,7 @@
|
|||
v-if="$refs.player"
|
||||
:current-time="$refs.player.currentTime"
|
||||
:duration="$refs.player.duration"
|
||||
:controls="controls"
|
||||
/>
|
||||
<v-spacer />
|
||||
<fullscreen
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div style="color: #fff; font-size: 0.75rem">
|
||||
{{ $vuetube.humanTime(currentTime) }}
|
||||
{{ humanWatchTime }}
|
||||
<span style="color: #aaa"> / {{ humanDuration }} </span>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue