From e730b77fcea6b9d5278c0b81da0d080301baa608 Mon Sep 17 00:00:00 2001 From: db123 Date: Thu, 23 Apr 2026 00:41:38 +0330 Subject: [PATCH] feat: made it accept both video id and element --- src/core/VideoPlayer.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/VideoPlayer.ts b/src/core/VideoPlayer.ts index 85d6ce8..68c7a70 100644 --- a/src/core/VideoPlayer.ts +++ b/src/core/VideoPlayer.ts @@ -5,7 +5,7 @@ * creation: 21/4/2026 */ -import { PlayerConfig, HLSOptions, DASHOptions } from "../types/index"; +import { PlayerConfig } from "../types/index"; export class VP { videoElement: HTMLElement | null; @@ -16,9 +16,13 @@ export class VP { * @param {string} video The targeted video element * @param {PlayerConfig} config The config array */ - constructor(video: string, config: PlayerConfig) { + constructor(video: string | HTMLVideoElement, config: PlayerConfig) { this.config = config; - this.videoElement = document.querySelector(video); + if (video instanceof HTMLVideoElement) { + this.videoElement = video; + } else { + this.videoElement = document.querySelector(video); + } this.videoSources = this.videoElement?.querySelectorAll("source"); } }