mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-14 08:25:07 +01:00
Add basic controller
This commit is contained in:
parent
2097917286
commit
d99ddd65e2
@ -1,5 +1,21 @@
|
|||||||
import { Controller } from "@/stores/player/controllers/types";
|
import { Controller } from "@/stores/player/controllers/types";
|
||||||
|
|
||||||
function useBaseController(el: HTMLVideoElement): Controller {
|
export function useBaseController(): Controller {
|
||||||
return {};
|
let el: HTMLVideoElement | undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerVideoElement(video) {
|
||||||
|
el = video;
|
||||||
|
},
|
||||||
|
pause() {
|
||||||
|
el?.pause();
|
||||||
|
},
|
||||||
|
play() {
|
||||||
|
el?.play();
|
||||||
|
},
|
||||||
|
setVolume(target) {
|
||||||
|
if (!el) return;
|
||||||
|
el.volume = target;
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,5 @@ export interface Controller {
|
|||||||
pause(): void;
|
pause(): void;
|
||||||
play(): void;
|
play(): void;
|
||||||
setVolume(target: number): void;
|
setVolume(target: number): void;
|
||||||
registerVideoElement(): void;
|
registerVideoElement(videoElement: HTMLVideoElement): void;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user