Add support for hour, minute and second time paterns.

Closes #706
This commit is contained in:
FireMasterK 2022-01-12 04:52:15 +00:00
parent 5aaf80a3e2
commit 89ca5094a5
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -188,7 +188,25 @@ export default {
videoEl.setAttribute("poster", this.video.thumbnailUrl);
if (this.$route.query.t) {
videoEl.currentTime = this.$route.query.t;
const time = this.$route.query.t;
let start = 0;
if (/^[\d]*$/g.test(time)) {
start = time;
} else {
const hours = /([\d]*)h/gi.exec(time)?.[1];
const minutes = /([\d]*)m/gi.exec(time)?.[1];
const seconds = /([\d]*)s/gi.exec(time)?.[1];
if (hours) {
start += parseInt(hours) * 60 * 60;
}
if (minutes) {
start += parseInt(minutes) * 60;
}
if (seconds) {
start += parseInt(seconds);
}
}
videoEl.currentTime = start;
} else if (window.db) {
var tx = window.db.transaction("watch_history", "readonly");
var store = tx.objectStore("watch_history");