Add basic controller

This commit is contained in:
mrjvs 2023-09-01 15:52:39 +02:00
parent 2097917286
commit d99ddd65e2
2 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,21 @@
import { Controller } from "@/stores/player/controllers/types";
function useBaseController(el: HTMLVideoElement): Controller {
return {};
export function useBaseController(): Controller {
let el: HTMLVideoElement | undefined;
return {
registerVideoElement(video) {
el = video;
},
pause() {
el?.pause();
},
play() {
el?.play();
},
setVolume(target) {
if (!el) return;
el.volume = target;
},
};
}

View File

@ -2,5 +2,5 @@ export interface Controller {
pause(): void;
play(): void;
setVolume(target: number): void;
registerVideoElement(): void;
registerVideoElement(videoElement: HTMLVideoElement): void;
}