diff --git a/src/core/VideoPlayer.ts b/src/core/VideoPlayer.ts index 526b9a7..bc5363f 100644 --- a/src/core/VideoPlayer.ts +++ b/src/core/VideoPlayer.ts @@ -5,7 +5,7 @@ * creation: 21/4/2026 */ -import { NativeAdapter } from '../adapters'; +import { adapterRegistry } from '../adapters'; import { AdapterAPI, PlayerConfig } from '../types/index'; import { BaseUI } from '../ui'; @@ -29,7 +29,7 @@ export class VP { if (!this.config.type) { throw new Error('Type not specified in config.'); } - this.adapter = this.adapterInit(this.config.type); + this.adapter = adapterRegistry.createAdapter(this.config.type, this.video); if (config.controls) { this.ui = new BaseUI(this, this.video, this.config.prefixClass); @@ -65,26 +65,6 @@ https://git.db123.ir/db/VideoPlayer return videoEl; } - private adapterInit(type: string = 'native'): AdapterAPI { - switch (type) { - case 'native': { - return new NativeAdapter(this.video); - } - - case 'hls': { - throw new Error(`Adapter not implemented: ${type}`); - } - - case 'dash': { - throw new Error(`Adapter not implemented: ${type}`); - } - - default: { - throw new Error(`Adapter not found: ${type}`); - } - } - } - load(): void { this.adapter.load(); }