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

- 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:
1xDed committed 2026-11-30 19:19:51 +03:00
1 parent 5784036eb1
commit d9bce4de04
100 files changed
+1364 -706

No files matched your search

@@ -29,20 +29,20 @@ const ErrorDisplay = ({ error, onRetry, onExit }: ErrorDisplayProps) => {
}}
>
<Typography variant="h5" color="error">
Playback Error
Ошибка воспроизведения
</Typography>
<Typography variant="body1">
{error.message || "An unknown error occurred during playback."}
{error.message || "Во время воспроизведения произошла неизвестная ошибка."}
</Typography>
<div style={{ display: "flex", gap: "1rem" }}>
{onRetry && (
<Button variant="contained" color="primary" onClick={onRetry}>
Retry
Повторить
</Button>
)}
{onExit && (
<Button variant="outlined" color="secondary" onClick={onExit}>
Exit
Выйти
</Button>
)}
</div>
@@ -115,7 +115,7 @@ const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
fontWeight: "bold",
}}
>
Stats for Nerds
Статистика
</Typography>
<IconButton
size="small"
@@ -138,29 +138,29 @@ const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
gap: "0.5em 1em",
}}
>
<span>Video ID:</span> <span>{itemId}</span>
<span>Media Source ID:</span> <span>{mediaSourceId}</span>
<span>Play Session ID:</span> <span>{playsessionId}</span>
<span>Playback Method:</span> <span>{mediaSource.playMethod}</span>
<span>Container:</span> <span>{mediaSource.container}</span>
<span>Video Codec:</span> <span>{mediaSource.videoCodec}</span>
<span>Audio Codec:</span> <span>{mediaSource.audioCodec}</span>
<span>Bitrate:</span>{" "}
<span>ID видео:</span> <span>{itemId}</span>
<span>ID источника:</span> <span>{mediaSourceId}</span>
<span>ID сеанса:</span> <span>{playsessionId}</span>
<span>Метод воспроизведения:</span> <span>{mediaSource.playMethod}</span>
<span>Контейнер:</span> <span>{mediaSource.container}</span>
<span>Видеокодек:</span> <span>{mediaSource.videoCodec}</span>
<span>Аудиокодек:</span> <span>{mediaSource.audioCodec}</span>
<span>Битрейт:</span>{" "}
<span>
{mediaSource.bitrate
? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps`
: "-"}
</span>
<span>Stream URL:</span>{" "}
<span>URL потока:</span>{" "}
<span style={{ wordBreak: "break-all" }}>{playbackStream}</span>
<span>Resolution:</span> <span>{videoStats.resolution}</span>
<span>Volume:</span> <span>{Math.round(volume * 100)}%</span>
<span>Buffer Health:</span> <span>{videoStats.buffered}</span>
<span>Dropped Frames:</span>{" "}
<span>Разрешение:</span> <span>{videoStats.resolution}</span>
<span>Громкость:</span> <span>{Math.round(volume * 100)}%</span>
<span>Буфер:</span> <span>{videoStats.buffered}</span>
<span>Пропущенные кадры:</span>{" "}
<span>
{videoStats.droppedFrames} / {videoStats.totalFrames}
</span>
<span>Is Buffering:</span> <span>{isBuffering ? "Yes" : "No"}</span>
<span>Буферизация:</span> <span>{isBuffering ? "Да" : "Нет"}</span>
</div>
</Paper>
);
@@ -0,0 +1,94 @@
import { IconButton, Tooltip } from "@mui/material";
import { useSnackbar } from "notistack";
import React, { useEffect, useState } from "react";
import {
getPlayerVideoElement,
isPictureInPictureActive,
supportsPictureInPicture,
togglePictureInPicture,
} from "@/utils/methods/pictureInPicture";
import { usePlaybackStore } from "@/utils/store/playback";
const PictureInPictureButton = () => {
const playsessionId = usePlaybackStore((state) => state.playsessionId);
const { enqueueSnackbar } = useSnackbar();
const [supported, setSupported] = useState(() => supportsPictureInPicture());
const [active, setActive] = useState(false);
const [busy, setBusy] = useState(false);
useEffect(() => {
const update = () => {
const currentVideo = getPlayerVideoElement();
if (currentVideo) {
setSupported(supportsPictureInPicture(currentVideo));
}
setActive(currentVideo ? isPictureInPictureActive(currentVideo) : false);
};
const video = getPlayerVideoElement();
if (video) {
setSupported(supportsPictureInPicture(video));
setActive(isPictureInPictureActive(video));
}
document.addEventListener("enterpictureinpicture", update, true);
document.addEventListener("leavepictureinpicture", update, true);
document.addEventListener("webkitpresentationmodechanged", update, true);
const interval = window.setInterval(update, 1000);
return () => {
window.clearInterval(interval);
document.removeEventListener("enterpictureinpicture", update, true);
document.removeEventListener("leavepictureinpicture", update, true);
document.removeEventListener(
"webkitpresentationmodechanged",
update,
true,
);
};
}, [playsessionId]);
if (!supported) return null;
const label = active ? "Выйти из картинки в картинке" : "Картинка в картинке";
const handleClick = async () => {
const video = getPlayerVideoElement();
if (!video) {
enqueueSnackbar("Видео ещё не готово", { variant: "info" });
return;
}
try {
setBusy(true);
await togglePictureInPicture(video);
setActive(isPictureInPictureActive(video));
} catch (error) {
console.error("Picture-in-picture failed", error);
enqueueSnackbar("Не удалось включить картинку в картинке", {
variant: "error",
});
} finally {
setBusy(false);
}
};
return (
<Tooltip title={label}>
<span>
<IconButton
onClick={handleClick}
disabled={busy}
aria-label={label}
title={label}
>
<span className="material-symbols-rounded fill">
{active ? "picture_in_picture" : "picture_in_picture_alt"}
</span>
</IconButton>
</span>
</Tooltip>
);
};
export default PictureInPictureButton;
@@ -35,7 +35,7 @@ const SkipSegmentButton = () => {
currentSegmentIndex >= 0 &&
activeSegmentId &&
(segmentType !== "Outro" || !hasNextItem);
const label = segmentType === "Outro" ? "Skip credits" : `Skip ${segmentType}`;
const label = segmentType === "Outro" ? "Пропустить титры" : segmentType === "Intro" ? "Пропустить интро" : segmentType === "Recap" ? "Пропустить рекап" : segmentType === "Commercial" ? "Пропустить рекламу" : segmentType === "Preview" ? "Пропустить превью" : "Пропустить";
return (
<AnimatePresence>
@@ -0,0 +1,93 @@
import {
IconButton,
ListItemIcon,
ListItemText,
Menu,
MenuItem,
Tooltip,
} from "@mui/material";
import React, { useState } from "react";
import type { VideoFitMode } from "@/utils/types/videoFitMode";
const OPTIONS: Array<{
value: VideoFitMode;
label: string;
icon: string;
hint: string;
}> = [
{
value: "fit",
label: "По размеру",
icon: "fit_screen",
hint: "Вписать видео целиком",
},
{
value: "fill",
label: "Заполнить экран",
icon: "zoom_out_map",
hint: "Убрать полосы, обрезав края",
},
{
value: "stretch",
label: "Растянуть",
icon: "aspect_ratio",
hint: "Растянуть на весь экран",
},
];
type VideoFitButtonProps = {
mode: VideoFitMode;
onChange: (mode: VideoFitMode) => void;
};
const VideoFitButton = ({ mode, onChange }: VideoFitButtonProps) => {
const [anchor, setAnchor] = useState<HTMLButtonElement | null>(null);
const current = OPTIONS.find((option) => option.value === mode) ?? OPTIONS[0];
return (
<>
<Tooltip title={`Режим изображения: ${current.label}`}>
<IconButton
onClick={(event) => setAnchor(event.currentTarget)}
aria-label="Режим изображения"
>
<span className="material-symbols-rounded">aspect_ratio</span>
</IconButton>
</Tooltip>
<Menu
anchorEl={anchor}
open={Boolean(anchor)}
onClose={() => setAnchor(null)}
anchorOrigin={{ vertical: "top", horizontal: "center" }}
transformOrigin={{ vertical: "bottom", horizontal: "center" }}
slotProps={{ paper: { className: "glass-menu-paper" } }}
>
{OPTIONS.map((option) => (
<MenuItem
key={option.value}
selected={option.value === mode}
onClick={() => {
onChange(option.value);
setAnchor(null);
}}
>
<ListItemIcon>
<span className="material-symbols-rounded">{option.icon}</span>
</ListItemIcon>
<ListItemText primary={option.label} secondary={option.hint} />
{option.value === mode && (
<span
className="material-symbols-rounded"
style={{ marginLeft: "1em" }}
>
check
</span>
)}
</MenuItem>
))}
</Menu>
</>
);
};
export default VideoFitButton;
@@ -1,10 +1,34 @@
.video-player {
--media-object-fit: contain;
background: black;
position: absolute;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
video {
object-fit: var(--media-object-fit);
}
&.video-fit-fill {
--media-object-fit: cover;
}
&.video-fit-stretch {
--media-object-fit: fill;
}
&-drag-region {
position: absolute;
inset: 0 0 auto;
height: 38px;
z-index: 4;
cursor: default;
user-select: none;
}
&-osd {
position: absolute;
width: 100vw;
@@ -27,6 +51,29 @@
&.hovering {
cursor: default;
}
&-back,
&-actions {
position: absolute;
top: 2em;
z-index: 3;
display: flex;
align-items: center;
padding: 0.3em;
border-radius: 999px;
border: 1px solid rgb(255 255 255 / 0.08);
background: rgb(0 0 0 / 0.28);
backdrop-filter: blur(12px);
}
&-back {
left: 3em;
}
&-actions {
right: 3em;
gap: 0.35em;
}
&-info {
margin-top: auto;
}
&-controls {
display: flex;
flex-direction: column;
+101 -12
View File
@@ -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>
@@ -156,7 +156,7 @@ const VideoPlayerSettingsMenu = ({
>
<TextField
select
label="Audio"
label="Аудио"
variant="outlined"
value={mediaSource.audio?.track}
onChange={handleAudioTrackChange}
@@ -171,7 +171,7 @@ const VideoPlayerSettingsMenu = ({
</TextField>
<TextField
select
label="Subtitles"
label="Субтитры"
variant="outlined"
value={mediaSource.subtitle?.track}
onChange={handleSubtitleChange}
@@ -179,7 +179,7 @@ const VideoPlayerSettingsMenu = ({
disabled={mediaSource.subtitle?.track === -2 || subtitleIsChanging}
>
<MenuItem key={-1} value={-1}>
No Subtitle
Без субтитров
</MenuItem>
{mediaSource.subtitle?.allTracks?.map((sub) => (
<MenuItem key={sub.Index} value={sub.Index}>
@@ -194,7 +194,7 @@ const VideoPlayerSettingsMenu = ({
flexGrow: 1,
}}
>
Stats for Nerds
Статистика
</Typography>
<Switch checked={showStatsForNerds} />
</MenuItem>
@@ -204,7 +204,7 @@ const VideoPlayerSettingsMenu = ({
flexGrow: 1,
}}
>
Sync playback
Синхронизация воспроизведения
</Typography>
<Switch
checked={syncForThisVideo}
@@ -219,7 +219,7 @@ const VideoPlayerSettingsMenu = ({
flexGrow: 1,
}}
>
Auto-skip intro &amp; recap
Автопропуск заставок, рекапов, рекламы и превью
</Typography>
<Switch
checked={autoSkip}
@@ -106,7 +106,7 @@ const UpNextFlyout = () => {
quality: 90,
fillWidth: 320,
})}
alt="next item thumbnail"
alt="Миниатюра следующего элемента"
style={{
width: "100%",
height: "100%",
@@ -142,7 +142,7 @@ const UpNextFlyout = () => {
letterSpacing: 1.2,
}}
>
UP NEXT
ДАЛЕЕ
</Typography>
<Typography
variant="h6"
@@ -192,7 +192,7 @@ const UpNextFlyout = () => {
flex: 1,
}}
>
Play Now
Смотреть
</Button>
<IconButton
onClick={() => setIsHidden(true)}