mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-19 02:34:17 +01:00
chore: refactor controls (#946)
Co-authored-by: Gauvain <68083474+Gauvino@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
cd920e2d84
commit
8389404975
14
components/video-player/controls/utils/progressUtils.ts
Normal file
14
components/video-player/controls/utils/progressUtils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { ticksToMs } from "@/utils/time";
|
||||
|
||||
export const initializeProgress = (item: BaseItemDto, isVlc: boolean) => {
|
||||
const initialProgress = isVlc
|
||||
? ticksToMs(item?.UserData?.PlaybackPositionTicks)
|
||||
: item?.UserData?.PlaybackPositionTicks || 0;
|
||||
|
||||
const maxProgress = isVlc
|
||||
? ticksToMs(item.RunTimeTicks || 0)
|
||||
: item.RunTimeTicks || 0;
|
||||
|
||||
return { initialProgress, maxProgress };
|
||||
};
|
||||
23
components/video-player/controls/utils/trickplayUtils.ts
Normal file
23
components/video-player/controls/utils/trickplayUtils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { TRICKPLAY_TILE_SCALE, TRICKPLAY_TILE_WIDTH } from "../constants";
|
||||
|
||||
export const calculateTrickplayDimensions = (aspectRatio: number) => {
|
||||
const tileWidth = TRICKPLAY_TILE_WIDTH;
|
||||
const tileHeight = TRICKPLAY_TILE_WIDTH / aspectRatio;
|
||||
|
||||
return {
|
||||
tileWidth,
|
||||
tileHeight,
|
||||
scaledWidth: tileWidth * TRICKPLAY_TILE_SCALE,
|
||||
scaledHeight: tileHeight * TRICKPLAY_TILE_SCALE,
|
||||
};
|
||||
};
|
||||
|
||||
export const formatTimeForBubble = (time: {
|
||||
hours: number;
|
||||
minutes: number;
|
||||
seconds: number;
|
||||
}) => {
|
||||
return `${time.hours > 0 ? `${time.hours}:` : ""}${
|
||||
time.minutes < 10 ? `0${time.minutes}` : time.minutes
|
||||
}:${time.seconds < 10 ? `0${time.seconds}` : time.seconds}`;
|
||||
};
|
||||
Reference in New Issue
Block a user