1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

player jumps

This commit is contained in:
Fedor Katurov 2019-10-11 14:06:12 +07:00
parent e198b59fc6
commit 1825746a0d

View file

@ -11,6 +11,9 @@ export class PlayerClass {
const { duration: total, currentTime: current } = this.element;
const progress = (current / total) * 100;
this.current = current || 0;
this.total = total || 0;
this.element.dispatchEvent(
new CustomEvent('playprogress', {
detail: { current, total, progress },
@ -19,6 +22,10 @@ export class PlayerClass {
});
}
public current: number = 0;
public total: number = 0;
public element: HTMLAudioElement = new Audio();
public duration: number = 0;
@ -46,6 +53,14 @@ export class PlayerClass {
public getDuration = () => {
return this.element.currentTime;
};
public jumpToTime = (time: number) => {
this.element.currentTime = time;
};
public jumpToPercent = (percent: number) => {
this.element.currentTime = (this.total * percent) / 100;
};
}
const Player = new PlayerClass();