mirror of
https://github.com/stashapp/stash.git
synced 2026-02-09 00:42:54 +01:00
27 lines
678 B
TypeScript
27 lines
678 B
TypeScript
import videojs, { VideoJsPlayer } from "video.js";
|
|
|
|
export const VIDEO_PLAYER_ID = "VideoJsPlayer";
|
|
|
|
export const getPlayer = () => videojs.getPlayer(VIDEO_PLAYER_ID);
|
|
|
|
export const getPlayerPosition = () => getPlayer()?.currentTime();
|
|
|
|
export type AbLoopOptions = {
|
|
start: number;
|
|
end: number | false;
|
|
enabled?: boolean;
|
|
};
|
|
|
|
export type AbLoopPluginApi = {
|
|
getOptions: () => AbLoopOptions;
|
|
setOptions: (options: AbLoopOptions) => void;
|
|
};
|
|
|
|
export const getAbLoopPlugin = () => {
|
|
const player = getPlayer();
|
|
if (!player) return null;
|
|
const { abLoopPlugin } = player as VideoJsPlayer & {
|
|
abLoopPlugin?: AbLoopPluginApi;
|
|
};
|
|
return abLoopPlugin ?? null;
|
|
};
|