feat(core): removed adapter init and used registry

used the newly made AdapterRegistry to instantiate adapters
This commit is contained in:
2026-04-29 23:28:52 +03:30
parent f663957ace
commit 88ecabf17a

View File

@@ -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();
}