0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-25 12:45:17 +00:00

perf: Greatly reduce CPU impact while watching videos (stage 1/2)

This commit is contained in:
Kenny 2022-08-10 15:41:27 -04:00
parent 199c40d4e3
commit 0760e1537b
2 changed files with 22 additions and 1 deletions

View file

@ -1,7 +1,7 @@
<template>
<div style="color: #fff; font-size: 0.75rem">
{{ $vuetube.humanTime(currentTime) }}
<span style="color: #aaa"> / {{ $vuetube.humanTime(duration) }} </span>
<span style="color: #aaa"> / {{ humanDuration }} </span>
</div>
</template>
@ -17,5 +17,25 @@ export default {
required: true,
},
},
data() {
return {
humanDuration: 0,
}
},
methods: {
calcDuration() {
this.humanDuration = this.$vuetube.humanTime(this.duration);
}
},
mounted() {
//--- Only call 'calcDuration()' when 'this.duration' becomes defined ---//
const durationTimer = setInterval(() => {
if (this.duration) {
this.calcDuration();
return clearInterval(durationTimer);
}
}, 100);
//--- END Only call 'calcDuration()' when 'this.duration' becomes defined ---//
}
};
</script>

View file

@ -138,6 +138,7 @@ const module = {
}
// join the array into a string with : as a sepatrator
let returntext = levels.join(":");
console.log(returntext);
return returntext;
},
//--- End Convert Time To Human Readable String ---//