feat: made it accept both video id and element

This commit is contained in:
2026-04-23 00:41:38 +03:30
parent 7f450b04fb
commit e730b77fce

View File

@@ -5,7 +5,7 @@
* creation: 21/4/2026 * creation: 21/4/2026
*/ */
import { PlayerConfig, HLSOptions, DASHOptions } from "../types/index"; import { PlayerConfig } from "../types/index";
export class VP { export class VP {
videoElement: HTMLElement | null; videoElement: HTMLElement | null;
@@ -16,9 +16,13 @@ export class VP {
* @param {string} video The targeted video element * @param {string} video The targeted video element
* @param {PlayerConfig} config The config array * @param {PlayerConfig} config The config array
*/ */
constructor(video: string, config: PlayerConfig) { constructor(video: string | HTMLVideoElement, config: PlayerConfig) {
this.config = config; this.config = config;
if (video instanceof HTMLVideoElement) {
this.videoElement = video;
} else {
this.videoElement = document.querySelector(video); this.videoElement = document.querySelector(video);
}
this.videoSources = this.videoElement?.querySelectorAll("source"); this.videoSources = this.videoElement?.querySelectorAll("source");
} }
} }