feat: implemented and passed correct api of player
This commit is contained in:
@@ -30,11 +30,11 @@ export class NativeAdapter implements AdapterAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy(): void {
|
destroy(): void {
|
||||||
this.pause();
|
this.video.pause();
|
||||||
this.video.load();
|
this.video.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
seek(time: number): void {
|
private seek(time: number): void {
|
||||||
if (this.video.fastSeek) {
|
if (this.video.fastSeek) {
|
||||||
this.video.fastSeek(time);
|
this.video.fastSeek(time);
|
||||||
} else {
|
} else {
|
||||||
@@ -42,31 +42,30 @@ export class NativeAdapter implements AdapterAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTime(): number {
|
get time(): number {
|
||||||
return this.video.currentTime;
|
return this.video.currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set time(time: number) {
|
||||||
|
this.seek(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
get volume(): number {
|
||||||
|
return this.video.volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
set volume(volume: number) {
|
||||||
|
this.video.volume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
get muted(): boolean {
|
||||||
|
return this.video.muted;
|
||||||
|
}
|
||||||
|
set muted(muted: boolean) {
|
||||||
|
this.video.muted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
duration(): number {
|
duration(): number {
|
||||||
return this.video.duration;
|
return this.video.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
volume(volume: number): void {
|
|
||||||
this.video.volume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentVolume(): number {
|
|
||||||
return this.video.volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
mute(muted?: boolean): void {
|
|
||||||
if (muted !== undefined) {
|
|
||||||
this.video.muted = muted;
|
|
||||||
} else {
|
|
||||||
this.video.muted = !this.video.muted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
muted(): boolean {
|
|
||||||
return this.video.muted;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class VP {
|
|||||||
private video: HTMLVideoElement | null;
|
private video: HTMLVideoElement | null;
|
||||||
private videoSrc?: NodeListOf<HTMLSourceElement>;
|
private videoSrc?: NodeListOf<HTMLSourceElement>;
|
||||||
private config?: PlayerConfig;
|
private config?: PlayerConfig;
|
||||||
private adapter?: AdapterAPI;
|
private adapter: AdapterAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param video The targeted video element or id
|
* @param video The targeted video element or id
|
||||||
@@ -33,4 +33,47 @@ export class VP {
|
|||||||
this.videoSrc = this.video?.querySelectorAll("source");
|
this.videoSrc = this.video?.querySelectorAll("source");
|
||||||
this.adapter = new NativeAdapter(this.video);
|
this.adapter = new NativeAdapter(this.video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load(): void {
|
||||||
|
this.adapter.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
play(): void {
|
||||||
|
this.adapter.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
pause(): void {
|
||||||
|
this.adapter.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy(): void {
|
||||||
|
this.adapter.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
get time(): number {
|
||||||
|
return this.adapter.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
set time(time: number) {
|
||||||
|
this.adapter.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
get volume(): number {
|
||||||
|
return this.adapter.volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
set volume(volume: number) {
|
||||||
|
this.adapter.volume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
get muted(): boolean {
|
||||||
|
return this.adapter.muted;
|
||||||
|
}
|
||||||
|
set muted(muted: boolean) {
|
||||||
|
this.adapter.muted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
duration(): number {
|
||||||
|
return this.adapter.duration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user