mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-16 16:25:17 +00:00
feat: ✨ beta player time info
This commit is contained in:
parent
9acc1ceef4
commit
cce0d90802
3 changed files with 30 additions and 25 deletions
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bottomVideoControls">
|
<div class="bottomVideoControls">
|
||||||
{{ watched }} <span style="color: #999;">/ {{ video.duration }}</span>
|
{{ watched }} <span style="color: #999;">/ {{ $vuetube.humanTime(video.duration) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
mounted() {
|
mounted() {
|
||||||
this.video.ontimeupdate = () => {
|
this.video.ontimeupdate = () => {
|
||||||
console.log(this.video.currentTime)
|
console.log(this.video.currentTime)
|
||||||
this.watched = this.video.currentTime;
|
this.watched = this.$vuetube.humanTime(this.video.currentTime);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -77,28 +77,6 @@ function linkParser(url) {
|
||||||
}
|
}
|
||||||
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||||
|
|
||||||
//--- Convert Time To Human Readable String ---//
|
|
||||||
function humanTime(seconds) {
|
|
||||||
let levels = [
|
|
||||||
Math.floor(seconds / 31536000), //Years
|
|
||||||
Math.floor((seconds % 31536000) / 86400), //Days
|
|
||||||
Math.floor(((seconds % 31536000) % 86400) / 3600), //Hours
|
|
||||||
Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), //Minutes
|
|
||||||
(((seconds % 31536000) % 86400) % 3600) % 60, //Seconds
|
|
||||||
];
|
|
||||||
|
|
||||||
let returntext = new String();
|
|
||||||
for (const i in levels) {
|
|
||||||
const num = levels[i].toString().length == 1 ? "0"+levels[i] : levels[i]; // If Number Is Single Digit, Add 0 In Front
|
|
||||||
|
|
||||||
returntext += ":"+num;
|
|
||||||
}
|
|
||||||
while (returntext.startsWith(":00")) { returntext = returntext.substring(3); } // Remove Prepending 0s (eg. 00:00:00:01:00)
|
|
||||||
if (returntext.startsWith(":0")) { returntext = returntext.substring(2); } else { returntext = returntext.substring(1); } // Prevent Time Starting With 0 (eg. 01:00)
|
|
||||||
return returntext
|
|
||||||
}
|
|
||||||
//--- End Convert Time To Human Readable String ---//
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBetweenStrings,
|
getBetweenStrings,
|
||||||
hexToRgb,
|
hexToRgb,
|
||||||
|
@ -107,5 +85,5 @@ module.exports = {
|
||||||
getMutationByKey,
|
getMutationByKey,
|
||||||
linkParser,
|
linkParser,
|
||||||
delay,
|
delay,
|
||||||
parseEmoji,
|
parseEmoji
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,6 +109,33 @@ const module = {
|
||||||
rgbToHex(r, g, b) {
|
rgbToHex(r, g, b) {
|
||||||
return rgbToHex(r, g, b);
|
return rgbToHex(r, g, b);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//--- Convert Time To Human Readable String ---//
|
||||||
|
humanTime(seconds=0) {
|
||||||
|
seconds = Math.floor(seconds); // Not doing this seems to break the calculation
|
||||||
|
let levels = [
|
||||||
|
Math.floor(seconds / 31536000), //Years
|
||||||
|
Math.floor((seconds % 31536000) / 86400), //Days
|
||||||
|
Math.floor(((seconds % 31536000) % 86400) / 3600), //Hours
|
||||||
|
Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), //Minutes
|
||||||
|
(((seconds % 31536000) % 86400) % 3600) % 60, //Seconds
|
||||||
|
];
|
||||||
|
|
||||||
|
let returntext = new String();
|
||||||
|
for (const i in levels) {
|
||||||
|
const num = levels[i].toString().length == 1 ? "0"+levels[i] : levels[i]; // If Number Is Single Digit, Add 0 In Front
|
||||||
|
|
||||||
|
returntext += ":"+num;
|
||||||
|
}
|
||||||
|
while (returntext.startsWith(":00")) { returntext = returntext.substring(3); } // Remove Prepending 0s (eg. 00:00:00:01:00)
|
||||||
|
if (returntext.startsWith(":0")) { returntext = returntext.substring(2); } else { returntext = returntext.substring(1); } // Prevent Time Starting With 0 (eg. 01:00)
|
||||||
|
console.log("Human Time:", returntext)
|
||||||
|
return returntext;
|
||||||
|
}
|
||||||
|
//--- End Convert Time To Human Readable String ---//
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--- Start ---//
|
//--- Start ---//
|
||||||
|
|
Loading…
Reference in a new issue