feat: almost tried to use adapter but havent yet

This commit is contained in:
2026-04-23 01:25:45 +03:30
parent e0148573dc
commit 8278e313e5

View File

@@ -5,26 +5,32 @@
* creation: 21/4/2026 * creation: 21/4/2026
*/ */
import { NativeAdapter } from "../adapters";
import { AdapterAPI, PlayerConfig } from "../types/index"; import { AdapterAPI, PlayerConfig } from "../types/index";
export class VP { export class VP {
private videoElement: HTMLElement | null; private video: HTMLVideoElement | null;
private videoSources?: NodeListOf<HTMLSourceElement>; private videoSrc?: NodeListOf<HTMLSourceElement>;
private config?: PlayerConfig; private config?: PlayerConfig;
private adapter?: AdapterAPI; private adapter?: AdapterAPI;
/** /**
* @param {string} video The targeted video element * @param video The targeted video element or id
* @param {PlayerConfig} config The config array * @param config The config array
*/ */
constructor(video: string | HTMLVideoElement, config: PlayerConfig) { constructor(video: string | HTMLVideoElement, config: PlayerConfig) {
this.config = config; this.config = config;
if (video instanceof HTMLVideoElement) { if (video instanceof HTMLVideoElement) {
this.videoElement = video; this.video = video;
} else { } else {
this.videoElement = document.querySelector(video); this.video = document.querySelector(video);
} }
this.videoSources = this.videoElement?.querySelectorAll("source"); if (!this.video) {
let adapter = this.config["type"]; throw new Error(`Video element not found: ${video}`);
}
this.videoSrc = this.video?.querySelectorAll("source");
this.adapter = new NativeAdapter(this.video);
} }
} }