feat: localize UI and improve playback
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- translate the interface into Russian - add picture-in-picture and video fit modes - derive skip segments from Jellyfin chapter markers - align player navigation and add a window drag region - keep audio playback alive across routes
This commit is contained in:
1 parent
5784036eb1
commit
d9bce4de04
100 files changed
+1364
-706
No files matched your search
@@ -17,19 +17,23 @@ import QueueButton from "@/components/buttons/queueButton";
|
||||
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import { buildPlayDeepLink } from "@/utils/deepLinks";
|
||||
import { getPlayerVideoElement } from "@/utils/methods/pictureInPicture";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useShareStore } from "@/utils/store/share";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
||||
import CaptionsButton from "./buttons/CaptionsButton";
|
||||
import ChaptersListButton from "./buttons/ChaptersListButton";
|
||||
import ForwardButton from "./buttons/ForwardButton";
|
||||
import FullscreenButton from "./buttons/FullscreenButton";
|
||||
import NextChapterButton from "./buttons/NextChapterButton";
|
||||
import PictureInPictureButton from "./buttons/PictureInPictureButton";
|
||||
import PlayPauseButton from "./buttons/PlayPauseButton";
|
||||
import PrevChapterButton from "./buttons/PrevChapterButton";
|
||||
import RewindButton from "./buttons/RewindButton";
|
||||
import VideoFitButton from "./buttons/VideoFitButton";
|
||||
import EndsAtDisplay from "./EndsAtDisplay";
|
||||
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||
|
||||
@@ -48,12 +52,16 @@ type VideoPlayerControlsProps = {
|
||||
// isVisible: boolean;
|
||||
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
fitMode: VideoFitMode;
|
||||
onFitModeChange: (mode: VideoFitMode) => void;
|
||||
};
|
||||
|
||||
const VideoPlayerControls = ({
|
||||
// isVisible,
|
||||
onHover,
|
||||
onLeave,
|
||||
fitMode,
|
||||
onFitModeChange,
|
||||
}: VideoPlayerControlsProps) => {
|
||||
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -145,6 +153,69 @@ const VideoPlayerControls = ({
|
||||
|
||||
const [settingsMenuRef, setSettingsMenuRef] =
|
||||
useState<HTMLButtonElement | null>(null);
|
||||
const [videoFrame, setVideoFrame] = useState<{
|
||||
top: number;
|
||||
left: number;
|
||||
right: number;
|
||||
} | null>(null);
|
||||
|
||||
// Keep the back button and the top action buttons on one line inside the
|
||||
// visible video area, below any letterbox bars.
|
||||
useEffect(() => {
|
||||
let frame = 0;
|
||||
const update = () => {
|
||||
const video = getPlayerVideoElement();
|
||||
if (!video) return;
|
||||
|
||||
const rect = video.getBoundingClientRect();
|
||||
const ratio =
|
||||
video.videoWidth > 0 && video.videoHeight > 0
|
||||
? video.videoWidth / video.videoHeight
|
||||
: null;
|
||||
const contentWidth = ratio
|
||||
? Math.min(rect.width, rect.height * ratio)
|
||||
: rect.width;
|
||||
const contentHeight = ratio ? contentWidth / ratio : rect.height;
|
||||
const contentLeft = rect.left + (rect.width - contentWidth) / 2;
|
||||
const contentTop = rect.top + (rect.height - contentHeight) / 2;
|
||||
|
||||
setVideoFrame((current) => {
|
||||
const next = {
|
||||
// 14% keeps the controls inside the picture even when the
|
||||
// file has letterbox bars baked into a 16:9 frame.
|
||||
top: Math.round(
|
||||
contentTop + Math.max(28, contentHeight * 0.14),
|
||||
),
|
||||
left: Math.round(contentLeft + 24),
|
||||
right: Math.round(
|
||||
window.innerWidth - contentLeft - contentWidth + 24,
|
||||
),
|
||||
};
|
||||
return current?.top === next.top &&
|
||||
current?.left === next.left &&
|
||||
current?.right === next.right
|
||||
? current
|
||||
: next;
|
||||
});
|
||||
};
|
||||
const schedule = () => {
|
||||
cancelAnimationFrame(frame);
|
||||
frame = requestAnimationFrame(update);
|
||||
};
|
||||
|
||||
schedule();
|
||||
const video = getPlayerVideoElement();
|
||||
video?.addEventListener("loadedmetadata", schedule);
|
||||
window.addEventListener("resize", schedule);
|
||||
const interval = window.setInterval(schedule, 1000);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(frame);
|
||||
window.clearInterval(interval);
|
||||
video?.removeEventListener("loadedmetadata", schedule);
|
||||
window.removeEventListener("resize", schedule);
|
||||
};
|
||||
}, [playsessionId]);
|
||||
|
||||
// const creditInfo = mediaSegments?.Items?.find(
|
||||
// (segment) => segment.Type === "Outro",
|
||||
@@ -229,14 +300,30 @@ const VideoPlayerControls = ({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="video-player-osd-header flex flex-justify-spaced-between flex-align-center">
|
||||
<div
|
||||
className="video-player-osd-back"
|
||||
style={
|
||||
videoFrame
|
||||
? { top: videoFrame.top, left: videoFrame.left }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleExitPlayer}
|
||||
aria-label="Exit player"
|
||||
title="Exit player"
|
||||
aria-label="Выйти из плеера"
|
||||
title="Выйти из плеера"
|
||||
>
|
||||
<span className="material-symbols-rounded">arrow_back</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="video-player-osd-actions"
|
||||
style={
|
||||
videoFrame
|
||||
? { top: videoFrame.top, right: videoFrame.right }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
useShareStore
|
||||
@@ -246,25 +333,25 @@ const VideoPlayerControls = ({
|
||||
itemId ?? "",
|
||||
currentTime > 0 ? ticksToSec(currentTime) : getCurrentTime(),
|
||||
),
|
||||
"Share this scene",
|
||||
"Поделиться этой сценой",
|
||||
)
|
||||
}
|
||||
aria-label="Share scene"
|
||||
title="Share scene"
|
||||
aria-label="Поделиться сценой"
|
||||
title="Поделиться сценой"
|
||||
>
|
||||
<span className="material-symbols-rounded">share</span>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={openSyncPlayDialog}
|
||||
aria-label="Watch together"
|
||||
title="Watch together"
|
||||
aria-label="Смотреть вместе"
|
||||
title="Смотреть вместе"
|
||||
>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
||||
aria-label="Player settings"
|
||||
title="Player settings"
|
||||
aria-label="Настройки плеера"
|
||||
title="Настройки плеера"
|
||||
>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</IconButton>
|
||||
@@ -372,10 +459,10 @@ const VideoPlayerControls = ({
|
||||
})}
|
||||
/>
|
||||
<Tooltip
|
||||
title={syncThisVideo ? "Stop device sync" : "Sync playback"}
|
||||
title={syncThisVideo ? "Остановить синхронизацию" : "Синхронизация воспроизведения"}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="Sync playback"
|
||||
aria-label="Синхронизация воспроизведения"
|
||||
onClick={toggleSync}
|
||||
sx={
|
||||
syncThisVideo
|
||||
@@ -390,7 +477,9 @@ const VideoPlayerControls = ({
|
||||
|
||||
<ChaptersListButton />
|
||||
|
||||
<VideoFitButton mode={fitMode} onChange={onFitModeChange} />
|
||||
<CaptionsButton />
|
||||
<PictureInPictureButton />
|
||||
<FullscreenButton />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user