refactor: saved all files with prettier formatting
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* creation: 23/4/2026
|
* creation: 23/4/2026
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AdapterAPI } from "../types";
|
import { AdapterAPI } from '../types';
|
||||||
|
|
||||||
export class NativeAdapter implements AdapterAPI {
|
export class NativeAdapter implements AdapterAPI {
|
||||||
private video: HTMLVideoElement;
|
private video: HTMLVideoElement;
|
||||||
@@ -22,7 +22,7 @@ export class NativeAdapter implements AdapterAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
play(): void {
|
play(): void {
|
||||||
this.video.play().catch((e) => console.warn("Play failed:", e));
|
this.video.play().catch((e) => console.warn('Play failed:', e));
|
||||||
}
|
}
|
||||||
|
|
||||||
pause(): void {
|
pause(): void {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { NativeAdapter } from "./Native";
|
export { NativeAdapter } from './Native';
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
* creation: 21/4/2026
|
* creation: 21/4/2026
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NativeAdapter } from "../adapters";
|
import { NativeAdapter } from '../adapters';
|
||||||
import { AdapterAPI, PlayerConfig } from "../types/index";
|
import { AdapterAPI, PlayerConfig } from '../types/index';
|
||||||
import { BaseUI } from "../ui";
|
import { BaseUI } from '../ui';
|
||||||
|
|
||||||
export class VP {
|
export class VP {
|
||||||
private video: HTMLVideoElement;
|
private video: HTMLVideoElement;
|
||||||
@@ -24,10 +24,10 @@ export class VP {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
this.video = this.videoElement(video);
|
this.video = this.videoElement(video);
|
||||||
this.videoSrc = this.video?.querySelectorAll<HTMLSourceElement>("source");
|
this.videoSrc = this.video?.querySelectorAll<HTMLSourceElement>('source');
|
||||||
|
|
||||||
if (!this.config.type) {
|
if (!this.config.type) {
|
||||||
throw new Error("Type not specified in config.");
|
throw new Error('Type not specified in config.');
|
||||||
}
|
}
|
||||||
this.adapter = this.adapterInit(this.config.type);
|
this.adapter = this.adapterInit(this.config.type);
|
||||||
|
|
||||||
@@ -65,17 +65,17 @@ https://git.db123.ir/db/VideoPlayer
|
|||||||
return videoEl;
|
return videoEl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private adapterInit(type: string = "native"): AdapterAPI {
|
private adapterInit(type: string = 'native'): AdapterAPI {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "native": {
|
case 'native': {
|
||||||
return new NativeAdapter(this.video);
|
return new NativeAdapter(this.video);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "hls": {
|
case 'hls': {
|
||||||
throw new Error(`Adapter not implemented: ${type}`);
|
throw new Error(`Adapter not implemented: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "dash": {
|
case 'dash': {
|
||||||
throw new Error(`Adapter not implemented: ${type}`);
|
throw new Error(`Adapter not implemented: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { VP } from "./VideoPlayer";
|
export { VP } from './VideoPlayer';
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { EventManager } from "./EventManager";
|
export { EventManager } from './EventManager';
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
* creation: 24/4/2026
|
* creation: 24/4/2026
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { VP } from "../core";
|
import { VP } from '../core';
|
||||||
import { EventManager } from "../events";
|
import { EventManager } from '../events';
|
||||||
|
|
||||||
export class BaseUI {
|
export class BaseUI {
|
||||||
private player: VP;
|
private player: VP;
|
||||||
@@ -18,7 +18,7 @@ export class BaseUI {
|
|||||||
private originalParent!: Node;
|
private originalParent!: Node;
|
||||||
private nextSibling: ChildNode | null = null;
|
private nextSibling: ChildNode | null = null;
|
||||||
|
|
||||||
constructor(player: VP, video: HTMLVideoElement, prefixClass: string = "vp") {
|
constructor(player: VP, video: HTMLVideoElement, prefixClass: string = 'vp') {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.video = video;
|
this.video = video;
|
||||||
this.prefixClass = prefixClass;
|
this.prefixClass = prefixClass;
|
||||||
@@ -28,10 +28,10 @@ export class BaseUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private build(): void {
|
private build(): void {
|
||||||
const wrapper = document.createElement("div");
|
const wrapper = document.createElement('div');
|
||||||
wrapper.className = this.prefixClass + "-wrapper";
|
wrapper.className = this.prefixClass + '-wrapper';
|
||||||
const controlsWrap = document.createElement("div");
|
const controlsWrap = document.createElement('div');
|
||||||
controlsWrap.className = this.prefixClass + "-controls";
|
controlsWrap.className = this.prefixClass + '-controls';
|
||||||
|
|
||||||
const videoParent = this.video.parentNode;
|
const videoParent = this.video.parentNode;
|
||||||
if (!videoParent) {
|
if (!videoParent) {
|
||||||
@@ -58,19 +58,19 @@ export class BaseUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createPlayButton(): void {
|
private createPlayButton(): void {
|
||||||
const playButton = document.createElement("button");
|
const playButton = document.createElement('button');
|
||||||
playButton.className = this.prefixClass + "-playButton";
|
playButton.className = this.prefixClass + '-playButton';
|
||||||
if (this.video.paused) {
|
if (this.video.paused) {
|
||||||
playButton.innerText = "play";
|
playButton.innerText = 'play';
|
||||||
} else {
|
} else {
|
||||||
playButton.innerText = "pause";
|
playButton.innerText = 'pause';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.events.add(this.video, "play", function (): void {
|
this.events.add(this.video, 'play', function (): void {
|
||||||
playButton.innerText = "pause";
|
playButton.innerText = 'pause';
|
||||||
});
|
});
|
||||||
this.events.add(this.video, "pause", function (): void {
|
this.events.add(this.video, 'pause', function (): void {
|
||||||
playButton.innerText = "play";
|
playButton.innerText = 'play';
|
||||||
});
|
});
|
||||||
|
|
||||||
playButton.onclick = (): void => {
|
playButton.onclick = (): void => {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { BaseUI } from "./BaseUI";
|
export { BaseUI } from './BaseUI';
|
||||||
|
|||||||
Reference in New Issue
Block a user