mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
player jumps
This commit is contained in:
parent
e198b59fc6
commit
1825746a0d
1 changed files with 15 additions and 0 deletions
|
@ -11,6 +11,9 @@ export class PlayerClass {
|
||||||
const { duration: total, currentTime: current } = this.element;
|
const { duration: total, currentTime: current } = this.element;
|
||||||
const progress = (current / total) * 100;
|
const progress = (current / total) * 100;
|
||||||
|
|
||||||
|
this.current = current || 0;
|
||||||
|
this.total = total || 0;
|
||||||
|
|
||||||
this.element.dispatchEvent(
|
this.element.dispatchEvent(
|
||||||
new CustomEvent('playprogress', {
|
new CustomEvent('playprogress', {
|
||||||
detail: { current, total, progress },
|
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 element: HTMLAudioElement = new Audio();
|
||||||
|
|
||||||
public duration: number = 0;
|
public duration: number = 0;
|
||||||
|
@ -46,6 +53,14 @@ export class PlayerClass {
|
||||||
public getDuration = () => {
|
public getDuration = () => {
|
||||||
return this.element.currentTime;
|
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();
|
const Player = new PlayerClass();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue