mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-10-31 17:02:38 +00:00
merge main with dev
This commit is contained in:
commit
f93dd684a3
3 changed files with 29 additions and 19 deletions
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
|
||||
<div class="bottomVideoControls">
|
||||
{{ watched }} <span style="color: #999;">/ {{ video.duration }}</span>
|
||||
{{ watched }} <span style="color: #999;">/ {{ $vuetube.humanTime(video.duration) }}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -67,7 +67,7 @@
|
|||
mounted() {
|
||||
this.video.ontimeupdate = () => {
|
||||
console.log(this.video.currentTime)
|
||||
this.watched = this.video.currentTime;
|
||||
this.watched = this.$vuetube.humanTime(this.video.currentTime);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -77,22 +77,6 @@ function linkParser(url) {
|
|||
}
|
||||
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
//--- Convert Time To Human Readable String ---//
|
||||
function humanTime(givenTime) {
|
||||
const minutes = Math.floor(givenTime / 60);
|
||||
const seconds = givenTime - minutes * 60;
|
||||
const hours = Math.floor(givenTime / 3600);
|
||||
return {
|
||||
formatted: (hours ? hours+":" : "") + `${minutes}:${seconds}`,
|
||||
raw: {
|
||||
hours: hours,
|
||||
minutes: minutes,
|
||||
seconds: seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
//--- End Convert Time To Human Readable String ---//
|
||||
|
||||
module.exports = {
|
||||
getBetweenStrings,
|
||||
hexToRgb,
|
||||
|
@ -101,5 +85,5 @@ module.exports = {
|
|||
getMutationByKey,
|
||||
linkParser,
|
||||
delay,
|
||||
parseEmoji,
|
||||
parseEmoji
|
||||
};
|
||||
|
|
|
@ -129,6 +129,32 @@ const module = {
|
|||
back(listenerFunc) {
|
||||
backActions.back(listenerFunc);
|
||||
},
|
||||
|
||||
//--- 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 ---//
|
||||
|
|
Loading…
Reference in a new issue