feat: used new event manager for play button
This commit is contained in:
@@ -6,11 +6,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { VP } from "../core";
|
import { VP } from "../core";
|
||||||
|
import { EventManager } from "../events";
|
||||||
|
|
||||||
export class BaseUI {
|
export class BaseUI {
|
||||||
private player: VP;
|
private player: VP;
|
||||||
private video: HTMLVideoElement;
|
private video: HTMLVideoElement;
|
||||||
private prefixClass: string;
|
private prefixClass: string;
|
||||||
|
private events: EventManager;
|
||||||
private wrapper!: HTMLElement;
|
private wrapper!: HTMLElement;
|
||||||
private controlsWrap!: HTMLElement;
|
private controlsWrap!: HTMLElement;
|
||||||
private originalParent!: Node;
|
private originalParent!: Node;
|
||||||
@@ -20,6 +22,7 @@ export class BaseUI {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
this.video = video;
|
this.video = video;
|
||||||
this.prefixClass = prefixClass;
|
this.prefixClass = prefixClass;
|
||||||
|
this.events = new EventManager();
|
||||||
this.build();
|
this.build();
|
||||||
this.createPlayButton();
|
this.createPlayButton();
|
||||||
}
|
}
|
||||||
@@ -51,6 +54,7 @@ export class BaseUI {
|
|||||||
destroy(): void {
|
destroy(): void {
|
||||||
this.originalParent.insertBefore(this.video, this.nextSibling);
|
this.originalParent.insertBefore(this.video, this.nextSibling);
|
||||||
this.wrapper.remove();
|
this.wrapper.remove();
|
||||||
|
this.events.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private createPlayButton(): void {
|
private createPlayButton(): void {
|
||||||
@@ -62,10 +66,10 @@ export class BaseUI {
|
|||||||
playButton.innerText = "pause";
|
playButton.innerText = "pause";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.video.addEventListener("play", function (): void {
|
this.events.add(this.video, "play", function (): void {
|
||||||
playButton.innerText = "pause";
|
playButton.innerText = "pause";
|
||||||
});
|
});
|
||||||
this.video.addEventListener("pause", function (): void {
|
this.events.add(this.video, "pause", function (): void {
|
||||||
playButton.innerText = "play";
|
playButton.innerText = "play";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user