feat(player): add timeline metadata and simplify controls
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
Show chapter ticks, intro/recap/credits bands and a subtitle-derived dialogue density lane on the seek bar. Reduce the control bar to playback, volume, subtitles and fullscreen; move the remaining actions to settings or the top bar.
This commit is contained in:
1 parent
3e9e8698bc
commit
8ba09f9cfd
4 files changed
+275
-195
No files matched your search
@@ -1,6 +1,10 @@
|
|||||||
import type { TrickplayInfoDto } from "@jellyfin/sdk/lib/generated-client";
|
import type {
|
||||||
|
MediaSegmentDto,
|
||||||
|
TrickplayInfoDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { Slider, Tooltip, Typography } from "@mui/material";
|
import { Slider, Tooltip, Typography } from "@mui/material";
|
||||||
import type { Instance } from "@popperjs/core";
|
import type { Instance } from "@popperjs/core";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React, {
|
import React, {
|
||||||
type MouseEvent,
|
type MouseEvent,
|
||||||
useCallback,
|
useCallback,
|
||||||
@@ -14,6 +18,39 @@ import { ticksToMs } from "@/utils/date/time";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
|
||||||
|
const SEGMENT_LABELS: Record<string, string> = {
|
||||||
|
Intro: "Заставка",
|
||||||
|
Recap: "Ранее в серии",
|
||||||
|
Outro: "Титры",
|
||||||
|
Preview: "Следующая серия",
|
||||||
|
Commercial: "Реклама",
|
||||||
|
Unknown: "Сцена",
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseDialogueBuckets = (vtt: string, durationTicks: number) => {
|
||||||
|
const buckets = 220;
|
||||||
|
const counts = new Array(buckets).fill(0);
|
||||||
|
const durationSec = durationTicks / 10_000_000;
|
||||||
|
if (!durationSec) return counts;
|
||||||
|
|
||||||
|
const cueStart = /(\d{1,2}):(\d{2}):(\d{2})[.,](\d{3})\s*-->/g;
|
||||||
|
for (const match of vtt.matchAll(cueStart)) {
|
||||||
|
const seconds =
|
||||||
|
Number(match[1]) * 3600 +
|
||||||
|
Number(match[2]) * 60 +
|
||||||
|
Number(match[3]) +
|
||||||
|
Number(match[4]) / 1000;
|
||||||
|
const index = Math.min(
|
||||||
|
buckets - 1,
|
||||||
|
Math.max(0, Math.floor((seconds / durationSec) * buckets)),
|
||||||
|
);
|
||||||
|
counts[index] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const max = Math.max(...counts, 1);
|
||||||
|
return counts.map((count) => count / max);
|
||||||
|
};
|
||||||
|
|
||||||
const ticksDisplay = (ticks: number) => {
|
const ticksDisplay = (ticks: number) => {
|
||||||
const time = Math.round(ticks / 10000);
|
const time = Math.round(ticks / 10000);
|
||||||
let formatedTime = "";
|
let formatedTime = "";
|
||||||
@@ -50,6 +87,7 @@ const BubbleSlider = () => {
|
|||||||
mediaSource,
|
mediaSource,
|
||||||
itemTrickplay,
|
itemTrickplay,
|
||||||
itemId,
|
itemId,
|
||||||
|
mediaSegments,
|
||||||
handleStartSeek,
|
handleStartSeek,
|
||||||
handleStopSeek,
|
handleStopSeek,
|
||||||
} = usePlaybackStore(
|
} = usePlaybackStore(
|
||||||
@@ -65,6 +103,7 @@ const BubbleSlider = () => {
|
|||||||
mediaSource: state.mediaSource,
|
mediaSource: state.mediaSource,
|
||||||
itemTrickplay: state.metadata.item.Trickplay,
|
itemTrickplay: state.metadata.item.Trickplay,
|
||||||
itemId: state.metadata.item.Id,
|
itemId: state.metadata.item.Id,
|
||||||
|
mediaSegments: state.metadata.mediaSegments,
|
||||||
handleStartSeek: state.handleStartSeek,
|
handleStartSeek: state.handleStartSeek,
|
||||||
handleStopSeek: state.handleStopSeek,
|
handleStopSeek: state.handleStopSeek,
|
||||||
})),
|
})),
|
||||||
@@ -121,13 +160,44 @@ const BubbleSlider = () => {
|
|||||||
[itemDuration],
|
[itemDuration],
|
||||||
);
|
);
|
||||||
|
|
||||||
const chapterMarks = useMemo(() => {
|
const dialogueTrack = useMemo(() => {
|
||||||
const marks: { value: number }[] = [];
|
const tracks = mediaSource.subtitle?.allTracks ?? [];
|
||||||
itemChapters?.forEach((val) => {
|
return (
|
||||||
marks.push({ value: val.StartPositionTicks ?? 0 });
|
tracks.find(
|
||||||
});
|
(track) =>
|
||||||
return marks;
|
track.Index === mediaSource.subtitle?.track &&
|
||||||
}, [itemChapters]);
|
track.IsTextSubtitleStream,
|
||||||
|
) ?? tracks.find((track) => track.IsTextSubtitleStream)
|
||||||
|
);
|
||||||
|
}, [mediaSource.subtitle]);
|
||||||
|
|
||||||
|
const { data: dialogueBuckets } = useQuery({
|
||||||
|
queryKey: [
|
||||||
|
"video-dialogue-markers",
|
||||||
|
itemId,
|
||||||
|
mediaSource.id,
|
||||||
|
dialogueTrack?.Index,
|
||||||
|
itemDuration,
|
||||||
|
],
|
||||||
|
enabled: Boolean(
|
||||||
|
api && itemId && mediaSource.id && dialogueTrack && itemDuration,
|
||||||
|
),
|
||||||
|
staleTime: Number.POSITIVE_INFINITY,
|
||||||
|
retry: false,
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !itemId || !mediaSource.id || !dialogueTrack) return [];
|
||||||
|
const base = api.basePath.replace(/\/$/, "");
|
||||||
|
const response = await api.axiosInstance.get(
|
||||||
|
`${base}/Videos/${itemId}/${mediaSource.id}/Subtitles/${dialogueTrack.Index}/Stream.vtt`,
|
||||||
|
{ responseType: "text" },
|
||||||
|
);
|
||||||
|
const text =
|
||||||
|
typeof response.data === "string"
|
||||||
|
? response.data
|
||||||
|
: await response.data.text();
|
||||||
|
return parseDialogueBuckets(text, itemDuration ?? 0);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const sliderDisplayFormat = (value: number) => {
|
const sliderDisplayFormat = (value: number) => {
|
||||||
const currentChapter = itemChapters?.filter((chapter, index) => {
|
const currentChapter = itemChapters?.filter((chapter, index) => {
|
||||||
@@ -207,6 +277,14 @@ const BubbleSlider = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chapterName = currentChapter?.[0]?.Name;
|
const chapterName = currentChapter?.[0]?.Name;
|
||||||
|
const activeSegment: MediaSegmentDto | undefined =
|
||||||
|
mediaSegments?.Items?.find(
|
||||||
|
(segment) =>
|
||||||
|
value >= (segment.StartTicks ?? 0) && value < (segment.EndTicks ?? 0),
|
||||||
|
);
|
||||||
|
const segmentLabel = activeSegment?.Type
|
||||||
|
? SEGMENT_LABELS[activeSegment.Type]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -229,6 +307,21 @@ const BubbleSlider = () => {
|
|||||||
boxSizing: "border-box",
|
boxSizing: "border-box",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{segmentLabel && (
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
sx={{
|
||||||
|
display: "block",
|
||||||
|
mb: 0.35,
|
||||||
|
color: "rgba(255,255,255,0.6)",
|
||||||
|
letterSpacing: "0.04em",
|
||||||
|
textTransform: "uppercase",
|
||||||
|
fontSize: "0.62rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{segmentLabel}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
{chapterName && (
|
{chapterName && (
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
@@ -272,16 +365,12 @@ const BubbleSlider = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
// title={sliderDisplayFormat(
|
|
||||||
// positionRef.current.x - areaRef.current!.getBoundingClientRect().x,
|
|
||||||
// )}
|
|
||||||
title={sliderDisplayFormat(hoverProgress)}
|
title={sliderDisplayFormat(hoverProgress)}
|
||||||
placement="top"
|
placement="top"
|
||||||
slotProps={{
|
slotProps={{
|
||||||
popper: {
|
popper: {
|
||||||
popperRef,
|
popperRef,
|
||||||
anchorEl: virtualAnchorEl,
|
anchorEl: virtualAnchorEl,
|
||||||
// disablePortal: true,
|
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
className: "glass",
|
className: "glass",
|
||||||
@@ -295,52 +384,94 @@ const BubbleSlider = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Slider
|
<div className="video-player-timeline">
|
||||||
value={isUserSeeking ? seekValue : currentTime}
|
<div className="video-player-timeline-track" aria-hidden="true">
|
||||||
max={itemDuration ?? 0}
|
{mediaSegments?.Items?.map((segment) => {
|
||||||
step={1}
|
const start = segment.StartTicks ?? 0;
|
||||||
onChange={(_, newValue) => {
|
const end = segment.EndTicks ?? start;
|
||||||
// setIsUserSeeking(true);
|
if (!itemDuration || end <= start) return null;
|
||||||
Array.isArray(newValue)
|
return (
|
||||||
? handleStartSeek(newValue[0])
|
<span
|
||||||
: handleStartSeek(newValue);
|
key={segment.Id ?? `${segment.Type}-${start}`}
|
||||||
}}
|
className={`video-player-timeline-segment is-${(segment.Type ?? "unknown").toLowerCase()}`}
|
||||||
onChangeCommitted={(_, newValue) => {
|
style={{
|
||||||
// setIsUserSeeking(false);
|
left: `${(start / itemDuration) * 100}%`,
|
||||||
// Array.isArray(newValue)
|
width: `${((end - start) / itemDuration) * 100}%`,
|
||||||
// ? setSeekValue(newValue[0])
|
}}
|
||||||
// : setSeekValue(newValue);
|
/>
|
||||||
if (Array.isArray(newValue)) {
|
);
|
||||||
handleStopSeek(newValue[0]);
|
})}
|
||||||
} else {
|
{dialogueBuckets?.map((density, index) =>
|
||||||
handleStopSeek(newValue);
|
density > 0 ? (
|
||||||
}
|
<span
|
||||||
}}
|
// biome-ignore lint/suspicious/noArrayIndexKey: fixed density buckets
|
||||||
sx={{
|
key={`dialogue-${index}`}
|
||||||
"& .MuiSlider-thumb": {
|
className="video-player-timeline-dialogue"
|
||||||
width: 14,
|
style={{
|
||||||
height: 14,
|
left: `${(index / dialogueBuckets.length) * 100}%`,
|
||||||
transition: "0.1s ease-in-out",
|
height: `${Math.max(2, density * 8)}px`,
|
||||||
opacity: 0,
|
opacity: 0.25 + density * 0.55,
|
||||||
"&.Mui-active": {
|
}}
|
||||||
width: 20,
|
/>
|
||||||
height: 20,
|
) : null,
|
||||||
|
)}
|
||||||
|
{itemChapters?.map((chapter, index) => (
|
||||||
|
<span
|
||||||
|
key={`chapter-${chapter.StartPositionTicks ?? index}`}
|
||||||
|
className="video-player-timeline-chapter"
|
||||||
|
style={{
|
||||||
|
left: `${((chapter.StartPositionTicks ?? 0) / (itemDuration || 1)) * 100}%`,
|
||||||
|
}}
|
||||||
|
title={chapter.Name ?? undefined}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Slider
|
||||||
|
value={isUserSeeking ? seekValue : currentTime}
|
||||||
|
max={itemDuration ?? 0}
|
||||||
|
step={1}
|
||||||
|
onChange={(_, newValue) => {
|
||||||
|
// setIsUserSeeking(true);
|
||||||
|
Array.isArray(newValue)
|
||||||
|
? handleStartSeek(newValue[0])
|
||||||
|
: handleStartSeek(newValue);
|
||||||
|
}}
|
||||||
|
onChangeCommitted={(_, newValue) => {
|
||||||
|
// setIsUserSeeking(false);
|
||||||
|
// Array.isArray(newValue)
|
||||||
|
// ? setSeekValue(newValue[0])
|
||||||
|
// : setSeekValue(newValue);
|
||||||
|
if (Array.isArray(newValue)) {
|
||||||
|
handleStopSeek(newValue[0]);
|
||||||
|
} else {
|
||||||
|
handleStopSeek(newValue);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
"& .MuiSlider-thumb": {
|
||||||
|
width: 14,
|
||||||
|
height: 14,
|
||||||
|
transition: "0.1s ease-in-out",
|
||||||
|
opacity: 0,
|
||||||
|
"&.Mui-active": {
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"&:hover .MuiSlider-thumb": {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
},
|
},
|
||||||
},
|
"& .MuiSlider-rail": {
|
||||||
"&:hover .MuiSlider-thumb": {
|
opacity: 0.28,
|
||||||
opacity: 1,
|
background: "white",
|
||||||
},
|
},
|
||||||
"& .MuiSlider-rail": {
|
}}
|
||||||
opacity: 0.28,
|
valueLabelDisplay="off"
|
||||||
background: "white",
|
ref={areaRef}
|
||||||
},
|
onMouseMove={handleSliderHover}
|
||||||
}}
|
/>
|
||||||
marks={chapterMarks}
|
</div>
|
||||||
valueLabelDisplay="off"
|
|
||||||
ref={areaRef}
|
|
||||||
onMouseMove={handleSliderHover}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -168,41 +168,91 @@ html.is-macos .video-player-titlebar.is-fullscreen {
|
|||||||
|
|
||||||
.video-player-osd-controls {
|
.video-player-osd-controls {
|
||||||
gap: 0.6em;
|
gap: 0.6em;
|
||||||
|
|
||||||
> .flex.flex-row {
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .flex.flex-row > .video-player-osd-controls-buttons:last-child {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-player-osd-controls-buttons {
|
.video-player-osd-controls-buttons {
|
||||||
gap: 0.25em;
|
gap: 0.2em;
|
||||||
|
|
||||||
/* Keep previous, play/pause and next; drop the rest. */
|
|
||||||
> :nth-child(2),
|
|
||||||
> :nth-child(3),
|
|
||||||
> :nth-child(5),
|
|
||||||
> :nth-child(6),
|
|
||||||
> :nth-child(8) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiIconButton-root {
|
.MuiIconButton-root {
|
||||||
padding: 0.55em;
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
> :nth-child(4) .MuiIconButton-root {
|
.video-player-osd-controls-buttons:first-child
|
||||||
width: 52px;
|
> :nth-child(2)
|
||||||
height: 52px;
|
.MuiIconButton-root {
|
||||||
background: rgb(255 255 255 / 0.1);
|
width: 50px;
|
||||||
border-radius: 50%;
|
height: 50px;
|
||||||
}
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-player-osd-controls-timeline-text {
|
.video-player-osd-controls-timeline-text {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Timeline metadata: chapter ticks, intro/recap/credits bands and a thin
|
||||||
|
dialogue-density barcode under the rail. */
|
||||||
|
.video-player-timeline {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.MuiSlider-root {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-player-timeline-track {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 50%;
|
||||||
|
height: 12px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-player-timeline-segment {
|
||||||
|
position: absolute;
|
||||||
|
top: 7px;
|
||||||
|
height: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
opacity: 0.7;
|
||||||
|
background: rgb(255 255 255 / 0.4);
|
||||||
|
|
||||||
|
&.is-intro {
|
||||||
|
background: #5ee39a;
|
||||||
|
}
|
||||||
|
&.is-recap {
|
||||||
|
background: #7cb8ff;
|
||||||
|
}
|
||||||
|
&.is-outro {
|
||||||
|
background: #ffc46b;
|
||||||
|
}
|
||||||
|
&.is-preview {
|
||||||
|
background: #b48cff;
|
||||||
|
}
|
||||||
|
&.is-commercial {
|
||||||
|
background: #ff6b6b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-player-timeline-dialogue {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 1px;
|
||||||
|
border-radius: 1px;
|
||||||
|
background: rgb(255 255 255 / 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-player-timeline-chapter {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
width: 1px;
|
||||||
|
height: 8px;
|
||||||
|
background: rgb(255 255 255 / 0.55);
|
||||||
|
box-shadow: 0 0 4px rgb(0 0 0 / 0.45);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
import { IconButton, Slider, Tooltip, Typography } from "@mui/material";
|
import { IconButton, Slider, Typography } from "@mui/material";
|
||||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, {
|
import React, {
|
||||||
@@ -10,32 +10,17 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { AppStatusIndicator } from "@/components/appStatus";
|
|
||||||
import CastButton from "@/components/buttons/castButton";
|
import CastButton from "@/components/buttons/castButton";
|
||||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||||
import QueueButton from "@/components/buttons/queueButton";
|
|
||||||
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
||||||
import WindowControls from "@/components/windowControls";
|
import WindowControls from "@/components/windowControls";
|
||||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
import { secToTicks } from "@/utils/date/time";
|
||||||
import { buildPlayDeepLink } from "@/utils/deepLinks";
|
|
||||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
import { useShareStore } from "@/utils/store/share";
|
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
|
||||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
|
||||||
import CaptionsButton from "./buttons/CaptionsButton";
|
import CaptionsButton from "./buttons/CaptionsButton";
|
||||||
import ChaptersListButton from "./buttons/ChaptersListButton";
|
|
||||||
import ForwardButton from "./buttons/ForwardButton";
|
|
||||||
import FullscreenButton from "./buttons/FullscreenButton";
|
import FullscreenButton from "./buttons/FullscreenButton";
|
||||||
import NextChapterButton from "./buttons/NextChapterButton";
|
|
||||||
import PictureInPictureButton from "./buttons/PictureInPictureButton";
|
|
||||||
import PlayPauseButton from "./buttons/PlayPauseButton";
|
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";
|
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||||
|
|
||||||
import "./controls.scss";
|
import "./controls.scss";
|
||||||
@@ -52,32 +37,16 @@ type VideoPlayerControlsProps = {
|
|||||||
// isVisible: boolean;
|
// isVisible: boolean;
|
||||||
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
fitMode: VideoFitMode;
|
|
||||||
onFitModeChange: (mode: VideoFitMode) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const VideoPlayerControls = ({
|
const VideoPlayerControls = ({
|
||||||
// isVisible,
|
// isVisible,
|
||||||
onHover,
|
onHover,
|
||||||
onLeave,
|
onLeave,
|
||||||
fitMode,
|
|
||||||
onFitModeChange,
|
|
||||||
}: VideoPlayerControlsProps) => {
|
}: VideoPlayerControlsProps) => {
|
||||||
const playerOSDRef = useRef<HTMLDivElement>(null);
|
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const api = useApiInContext((state) => state.api);
|
const api = useApiInContext((state) => state.api);
|
||||||
const syncEnabled = useSyncPlayback((state) => state.enabled);
|
|
||||||
const syncMaster = useSyncPlayback((state) => state.master);
|
|
||||||
const startSync = useSyncPlayback((state) => state.start);
|
|
||||||
const stopSync = useSyncPlayback((state) => state.stop);
|
|
||||||
const syncThisVideo = syncEnabled && syncMaster?.sessionId === null;
|
|
||||||
const toggleSync = () => {
|
|
||||||
if (syncThisVideo) {
|
|
||||||
stopSync();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (itemId) startSync({ itemId, sessionId: null });
|
|
||||||
};
|
|
||||||
const {
|
const {
|
||||||
mediaSourceId,
|
mediaSourceId,
|
||||||
itemId,
|
itemId,
|
||||||
@@ -99,7 +68,6 @@ const VideoPlayerControls = ({
|
|||||||
decreaseVolumeByStep,
|
decreaseVolumeByStep,
|
||||||
getCurrentTime,
|
getCurrentTime,
|
||||||
isUserHovering,
|
isUserHovering,
|
||||||
currentTime,
|
|
||||||
} = usePlaybackStore(
|
} = usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
mediaSourceId: state.mediaSource.id,
|
mediaSourceId: state.mediaSource.id,
|
||||||
@@ -124,7 +92,6 @@ const VideoPlayerControls = ({
|
|||||||
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
||||||
getCurrentTime: state.getCurrentTime,
|
getCurrentTime: state.getCurrentTime,
|
||||||
isUserHovering: state.playerState.isUserHovering,
|
isUserHovering: state.playerState.isUserHovering,
|
||||||
currentTime: state.playerState.currentTime,
|
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -254,33 +221,17 @@ const VideoPlayerControls = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="video-player-titlebar-end">
|
<div className="video-player-titlebar-end">
|
||||||
<div className="video-player-osd-actions">
|
<div className="video-player-osd-actions">
|
||||||
<IconButton
|
<CastButton
|
||||||
onClick={() =>
|
item={item}
|
||||||
useShareStore
|
getTransfer={() => ({
|
||||||
.getState()
|
kind: "video",
|
||||||
.openShareDialog(
|
positionTicks: secToTicks(
|
||||||
buildPlayDeepLink(
|
usePlaybackStore.getState().getCurrentTime(),
|
||||||
itemId ?? "",
|
),
|
||||||
currentTime > 0
|
queue: useQueue.getState().tracks ?? [],
|
||||||
? ticksToSec(currentTime)
|
startIndex: useQueue.getState().currentItemIndex,
|
||||||
: getCurrentTime(),
|
})}
|
||||||
),
|
/>
|
||||||
"Поделиться этой сценой",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
aria-label="Поделиться сценой"
|
|
||||||
title="Поделиться сценой"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">share</span>
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
onClick={openSyncPlayDialog}
|
|
||||||
aria-label="Смотреть вместе"
|
|
||||||
title="Смотреть вместе"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">groups</span>
|
|
||||||
</IconButton>
|
|
||||||
<AppStatusIndicator />
|
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
||||||
aria-label="Настройки плеера"
|
aria-label="Настройки плеера"
|
||||||
@@ -327,17 +278,8 @@ const VideoPlayerControls = ({
|
|||||||
<div className="flex flex-row flex-justify-spaced-between">
|
<div className="flex flex-row flex-justify-spaced-between">
|
||||||
<div className="video-player-osd-controls-buttons">
|
<div className="video-player-osd-controls-buttons">
|
||||||
<PlayPreviousButton />
|
<PlayPreviousButton />
|
||||||
<RewindButton />
|
|
||||||
<PrevChapterButton />
|
|
||||||
|
|
||||||
<PlayPauseButton />
|
<PlayPauseButton />
|
||||||
|
|
||||||
<NextChapterButton />
|
|
||||||
|
|
||||||
<ForwardButton />
|
|
||||||
<PlayNextButton />
|
<PlayNextButton />
|
||||||
|
|
||||||
<EndsAtDisplay />
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="video-player-osd-controls-buttons"
|
className="video-player-osd-controls-buttons"
|
||||||
@@ -383,43 +325,7 @@ const VideoPlayerControls = ({
|
|||||||
: "volume_up"}
|
: "volume_up"}
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<CastButton
|
|
||||||
item={item}
|
|
||||||
getTransfer={() => ({
|
|
||||||
kind: "video",
|
|
||||||
positionTicks: secToTicks(
|
|
||||||
usePlaybackStore.getState().getCurrentTime(),
|
|
||||||
),
|
|
||||||
queue: useQueue.getState().tracks ?? [],
|
|
||||||
startIndex: useQueue.getState().currentItemIndex,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<Tooltip
|
|
||||||
title={
|
|
||||||
syncThisVideo
|
|
||||||
? "Остановить синхронизацию"
|
|
||||||
: "Синхронизация воспроизведения"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
aria-label="Синхронизация воспроизведения"
|
|
||||||
onClick={toggleSync}
|
|
||||||
sx={
|
|
||||||
syncThisVideo
|
|
||||||
? { color: "var(--mui-palette-primary-main)" }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">sync</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<QueueButton />
|
|
||||||
|
|
||||||
<ChaptersListButton />
|
|
||||||
|
|
||||||
<VideoFitButton mode={fitMode} onChange={onFitModeChange} />
|
|
||||||
<CaptionsButton />
|
<CaptionsButton />
|
||||||
<PictureInPictureButton />
|
|
||||||
<FullscreenButton />
|
<FullscreenButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -203,11 +203,6 @@ function VideoPlayer() {
|
|||||||
getVideoFitMode().then(setFitMode);
|
getVideoFitMode().then(setFitMode);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleFitModeChange = useCallback((mode: VideoFitMode) => {
|
|
||||||
setFitMode(mode);
|
|
||||||
void setVideoFitMode(mode);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const cycleFitMode = useCallback(() => {
|
const cycleFitMode = useCallback(() => {
|
||||||
setFitMode((current) => {
|
setFitMode((current) => {
|
||||||
const next =
|
const next =
|
||||||
@@ -820,8 +815,6 @@ function VideoPlayer() {
|
|||||||
// isVisible={areControlsVisible}
|
// isVisible={areControlsVisible}
|
||||||
onHover={handleMouseMove}
|
onHover={handleMouseMove}
|
||||||
onLeave={handleMouseLeave}
|
onLeave={handleMouseLeave}
|
||||||
fitMode={fitMode}
|
|
||||||
onFitModeChange={handleFitModeChange}
|
|
||||||
/>
|
/>
|
||||||
<SkipSegmentButton />
|
<SkipSegmentButton />
|
||||||
<VolumeChangeOverlay />
|
<VolumeChangeOverlay />
|
||||||
|
|||||||
Reference in new issue
Block a user