refactor: improve UI and fix videoplayer bugs
This commit is contained in:
12 files changed
+509
-160
No files matched your search
@@ -248,12 +248,16 @@ const PlayButton = ({
|
|||||||
(value) => value.Type === "Video",
|
(value) => value.Type === "Video",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isDirectPlay =
|
||||||
|
!result.mediaSource.MediaSources?.[0].SupportsTranscoding ||
|
||||||
|
!result.mediaSource.MediaSources?.[0].TranscodingUrl;
|
||||||
|
|
||||||
playItem({
|
playItem({
|
||||||
metadata: {
|
metadata: {
|
||||||
itemName: itemName ?? "",
|
itemName: itemName ?? "",
|
||||||
episodeTitle: episodeTitle,
|
episodeTitle: episodeTitle,
|
||||||
isEpisode: !!item.SeriesId,
|
isEpisode: !!item.SeriesId,
|
||||||
itemDuration: item.RunTimeTicks ?? 0,
|
itemDuration: playItemValue?.RunTimeTicks ?? item.RunTimeTicks ?? 0,
|
||||||
item: playItemValue ?? item,
|
item: playItemValue ?? item,
|
||||||
mediaSegments: result.mediaSegments,
|
mediaSegments: result.mediaSegments,
|
||||||
userDataLastPlayedPositionTicks: startPosition ?? 0,
|
userDataLastPlayedPositionTicks: startPosition ?? 0,
|
||||||
@@ -274,6 +278,12 @@ const PlayButton = ({
|
|||||||
enable: subtitle?.enable ?? false,
|
enable: subtitle?.enable ?? false,
|
||||||
},
|
},
|
||||||
audio: audio,
|
audio: audio,
|
||||||
|
bitrate: result.mediaSource.MediaSources?.[0].Bitrate,
|
||||||
|
videoCodec: videoTrack?.[0]?.Codec,
|
||||||
|
audioCodec: audio.allTracks?.find((t) => t.Index === audio.track)
|
||||||
|
?.Codec,
|
||||||
|
isDirectPlay: isDirectPlay,
|
||||||
|
transcodingUrl: result.mediaSource.MediaSources?.[0].TranscodingUrl,
|
||||||
},
|
},
|
||||||
playbackStream: playbackUrl,
|
playbackStream: playbackUrl,
|
||||||
playsessionId: result.mediaSource.PlaySessionId,
|
playsessionId: result.mediaSource.PlaySessionId,
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ const EndsAtDisplay = () => {
|
|||||||
const { currentTime, itemDuration } = usePlaybackStore(
|
const { currentTime, itemDuration } = usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
currentTime: state.playerState.currentTime,
|
currentTime: state.playerState.currentTime,
|
||||||
itemDuration: state.metadata.itemDuration,
|
itemDuration:
|
||||||
|
state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!itemDuration) return null;
|
if (!itemDuration) return <Typography variant="subtitle1">--:--</Typography>;
|
||||||
|
|
||||||
const remaining = itemDuration - (currentTime ?? 0);
|
const remaining = itemDuration - (currentTime ?? 0);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Button, Typography } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface ErrorDisplayProps {
|
||||||
|
error: any;
|
||||||
|
onRetry?: () => void;
|
||||||
|
onExit?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ErrorDisplay = ({ error, onRetry, onExit }: ErrorDisplayProps) => {
|
||||||
|
if (!error) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
zIndex: 100,
|
||||||
|
color: "white",
|
||||||
|
gap: "1rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="h5" color="error">
|
||||||
|
Playback Error
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body1">
|
||||||
|
{error.message || "An unknown error occurred during playback."}
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ErrorDisplay;
|
||||||
@@ -4,12 +4,13 @@ import { useShallow } from "zustand/shallow";
|
|||||||
import ticksDisplay from "@/utils/methods/ticksDisplay";
|
import ticksDisplay from "@/utils/methods/ticksDisplay";
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
|
||||||
const ProgressDislay = () => {
|
const ProgressDisplay = () => {
|
||||||
const { currentTime, itemDuration, isUserSeeking, seekValue } =
|
const { currentTime, itemDuration, isUserSeeking, seekValue } =
|
||||||
usePlaybackStore(
|
usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
currentTime: state.playerState.currentTime,
|
currentTime: state.playerState.currentTime,
|
||||||
itemDuration: state.metadata.itemDuration,
|
itemDuration:
|
||||||
|
state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks,
|
||||||
isUserSeeking: state.playerState.isUserSeeking,
|
isUserSeeking: state.playerState.isUserSeeking,
|
||||||
seekValue: state.playerState.seekValue,
|
seekValue: state.playerState.seekValue,
|
||||||
})),
|
})),
|
||||||
@@ -19,9 +20,9 @@ const ProgressDislay = () => {
|
|||||||
<Typography>
|
<Typography>
|
||||||
{ticksDisplay(isUserSeeking ? (seekValue ?? 0) : (currentTime ?? 0))}
|
{ticksDisplay(isUserSeeking ? (seekValue ?? 0) : (currentTime ?? 0))}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>{ticksDisplay(itemDuration)}</Typography>
|
<Typography>{ticksDisplay(itemDuration ?? 0)}</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProgressDislay;
|
export default ProgressDisplay;
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { IconButton, Paper, Typography } from "@mui/material";
|
||||||
|
import React, { type RefObject, useEffect, useState } from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
|
||||||
|
interface StatsForNerdsProps {
|
||||||
|
playerRef: RefObject<HTMLVideoElement>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
|
||||||
|
const {
|
||||||
|
showStatsForNerds,
|
||||||
|
toggleShowStatsForNerds,
|
||||||
|
itemId,
|
||||||
|
mediaSourceId,
|
||||||
|
playsessionId,
|
||||||
|
volume,
|
||||||
|
isBuffering,
|
||||||
|
playbackStream,
|
||||||
|
mediaSource,
|
||||||
|
} = usePlaybackStore(
|
||||||
|
useShallow((state) => ({
|
||||||
|
showStatsForNerds: state.playerState.showStatsForNerds,
|
||||||
|
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
||||||
|
itemId: state.metadata.item?.Id,
|
||||||
|
mediaSourceId: state.mediaSource.id,
|
||||||
|
playsessionId: state.playsessionId,
|
||||||
|
volume: state.playerState.volume,
|
||||||
|
isBuffering: state.playerState.isBuffering,
|
||||||
|
playbackStream: state.playbackStream,
|
||||||
|
mediaSource: state.mediaSource,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [videoStats, setVideoStats] = useState<{
|
||||||
|
resolution: string;
|
||||||
|
droppedFrames: number;
|
||||||
|
totalFrames: number;
|
||||||
|
buffered: string;
|
||||||
|
}>({
|
||||||
|
resolution: "-",
|
||||||
|
droppedFrames: 0,
|
||||||
|
totalFrames: 0,
|
||||||
|
buffered: "-",
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!showStatsForNerds) return;
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (playerRef.current) {
|
||||||
|
const internalPlayer = playerRef.current as HTMLVideoElement;
|
||||||
|
if (internalPlayer) {
|
||||||
|
const quality = internalPlayer.getVideoPlaybackQuality?.();
|
||||||
|
|
||||||
|
let bufferedEnd = 0;
|
||||||
|
if (internalPlayer.buffered.length > 0) {
|
||||||
|
// Find the buffered range that covers the current time
|
||||||
|
for (let i = 0; i < internalPlayer.buffered.length; i++) {
|
||||||
|
if (
|
||||||
|
internalPlayer.buffered.start(i) <=
|
||||||
|
internalPlayer.currentTime &&
|
||||||
|
internalPlayer.buffered.end(i) >= internalPlayer.currentTime
|
||||||
|
) {
|
||||||
|
bufferedEnd = internalPlayer.buffered.end(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setVideoStats({
|
||||||
|
resolution:
|
||||||
|
internalPlayer.videoWidth && internalPlayer.videoHeight
|
||||||
|
? `${internalPlayer.videoWidth}x${internalPlayer.videoHeight}`
|
||||||
|
: "-",
|
||||||
|
droppedFrames: quality?.droppedVideoFrames ?? 0,
|
||||||
|
totalFrames: quality?.totalVideoFrames ?? 0,
|
||||||
|
buffered: `${(bufferedEnd - internalPlayer.currentTime).toFixed(2)}s`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [showStatsForNerds, playerRef]);
|
||||||
|
|
||||||
|
if (!showStatsForNerds) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper
|
||||||
|
className="glass"
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "2em",
|
||||||
|
left: "2em",
|
||||||
|
padding: "1em",
|
||||||
|
color: "white",
|
||||||
|
zIndex: 100,
|
||||||
|
maxWidth: "400px",
|
||||||
|
fontSize: "0.8rem",
|
||||||
|
fontFamily: "monospace",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: "0.5em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2" fontWeight="bold">
|
||||||
|
Stats for Nerds
|
||||||
|
</Typography>
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onClick={toggleShowStatsForNerds}
|
||||||
|
sx={{ color: "white" }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ fontSize: "1.2rem" }}
|
||||||
|
>
|
||||||
|
close
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "auto 1fr",
|
||||||
|
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.isDirectPlay ? "Direct Play" : "Transcoding"}</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>
|
||||||
|
{mediaSource.bitrate
|
||||||
|
? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps`
|
||||||
|
: "-"}
|
||||||
|
</span>
|
||||||
|
<span>Stream 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>
|
||||||
|
{videoStats.droppedFrames} / {videoStats.totalFrames}
|
||||||
|
</span>
|
||||||
|
<span>Is Buffering:</span> <span>{isBuffering ? "Yes" : "No"}</span>
|
||||||
|
</div>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StatsForNerds;
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
import type { TrickplayInfo } from "@jellyfin/sdk/lib/generated-client";
|
import type { TrickplayInfo } 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 React, { type MouseEvent, useMemo, useRef, useState } from "react";
|
import React, {
|
||||||
|
type MouseEvent,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { ticksToMs } from "@/utils/date/time";
|
import { ticksToMs } from "@/utils/date/time";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -69,24 +76,54 @@ const BubbleSlider = () => {
|
|||||||
});
|
});
|
||||||
const popperRef = useRef<Instance>(null);
|
const popperRef = useRef<Instance>(null);
|
||||||
const areaRef = useRef<HTMLDivElement>(null);
|
const areaRef = useRef<HTMLDivElement>(null);
|
||||||
|
const rafRef = useRef<number | null>(null);
|
||||||
|
|
||||||
const [hoverProgress, setHoverProgress] = useState(0);
|
const [hoverProgress, setHoverProgress] = useState(0);
|
||||||
|
|
||||||
const handleSliderHover = (event: MouseEvent) => {
|
useEffect(() => {
|
||||||
positionRef.current = { x: event.clientX, y: event.clientY };
|
return () => {
|
||||||
const rect = areaRef.current!.getBoundingClientRect();
|
if (rafRef.current) {
|
||||||
|
cancelAnimationFrame(rafRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSliderHover = useCallback(
|
||||||
|
(event: MouseEvent) => {
|
||||||
|
const clientX = event.clientX;
|
||||||
|
const clientY = event.clientY;
|
||||||
|
|
||||||
|
if (
|
||||||
|
positionRef.current.x === clientX &&
|
||||||
|
positionRef.current.y === clientY
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positionRef.current = { x: clientX, y: clientY };
|
||||||
|
|
||||||
|
if (rafRef.current) return;
|
||||||
|
|
||||||
|
rafRef.current = requestAnimationFrame(() => {
|
||||||
|
if (areaRef.current) {
|
||||||
|
const rect = areaRef.current.getBoundingClientRect();
|
||||||
const width = rect.width;
|
const width = rect.width;
|
||||||
const distX = event.clientX - rect.left;
|
const distX = clientX - rect.left;
|
||||||
const percentageCovered = distX / width;
|
const percentageCovered = distX / width;
|
||||||
setHoverProgress(percentageCovered * (itemDuration ?? 0));
|
setHoverProgress(percentageCovered * (itemDuration ?? 0));
|
||||||
if (popperRef.current != null) {
|
if (popperRef.current != null) {
|
||||||
popperRef.current.update();
|
popperRef.current.update();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
rafRef.current = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[itemDuration],
|
||||||
|
);
|
||||||
|
|
||||||
const chapterMarks = useMemo(() => {
|
const chapterMarks = useMemo(() => {
|
||||||
const marks: { value: number }[] = [];
|
const marks: { value: number }[] = [];
|
||||||
itemChapters?.map((val) => {
|
itemChapters?.forEach((val) => {
|
||||||
marks.push({ value: val.StartPositionTicks ?? 0 });
|
marks.push({ value: val.StartPositionTicks ?? 0 });
|
||||||
});
|
});
|
||||||
return marks;
|
return marks;
|
||||||
@@ -95,14 +132,15 @@ const BubbleSlider = () => {
|
|||||||
const sliderDisplayFormat = (value: number) => {
|
const sliderDisplayFormat = (value: number) => {
|
||||||
const currentChapter = itemChapters?.filter((chapter, index) => {
|
const currentChapter = itemChapters?.filter((chapter, index) => {
|
||||||
if (index + 1 === itemChapters?.length) {
|
if (index + 1 === itemChapters?.length) {
|
||||||
return chapter;
|
return true;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(itemChapters?.[index + 1]?.StartPositionTicks ?? value) - value >= 0 &&
|
(itemChapters?.[index + 1]?.StartPositionTicks ?? value) - value >= 0 &&
|
||||||
(chapter.StartPositionTicks ?? value) - value < 0
|
(chapter.StartPositionTicks ?? value) - value < 0
|
||||||
) {
|
) {
|
||||||
return chapter;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
let trickplayResolution: TrickplayInfo | undefined;
|
let trickplayResolution: TrickplayInfo | undefined;
|
||||||
@@ -126,6 +164,8 @@ const BubbleSlider = () => {
|
|||||||
trickplayResolution = trickplayResolutions[bestWidth];
|
trickplayResolution = trickplayResolutions[bestWidth];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let trickplayStyle: React.CSSProperties | undefined;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
trickplayResolution?.TileWidth &&
|
trickplayResolution?.TileWidth &&
|
||||||
trickplayResolution.TileHeight &&
|
trickplayResolution.TileHeight &&
|
||||||
@@ -155,101 +195,105 @@ const BubbleSlider = () => {
|
|||||||
};
|
};
|
||||||
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
||||||
|
|
||||||
const imageAspectRatio =
|
const _imageAspectRatio =
|
||||||
trickplayResolution.Width / trickplayResolution.Height;
|
trickplayResolution.Width / trickplayResolution.Height;
|
||||||
|
|
||||||
if (currentChapter?.[0]?.Name) {
|
trickplayStyle = {
|
||||||
return (
|
|
||||||
<div className="flex flex-column video-osb-bubble">
|
|
||||||
<div
|
|
||||||
className="video-osd-trickplayBubble"
|
|
||||||
style={{
|
|
||||||
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||||
width: "100%",
|
width: `${trickplayResolution.Width}px`,
|
||||||
aspectRatio: imageAspectRatio,
|
height: `${trickplayResolution.Height}px`,
|
||||||
}}
|
borderBottom: "1px solid rgba(255,255,255,0.1)",
|
||||||
/>
|
borderRadius: 0,
|
||||||
<Typography variant="h6" px="12px" pt={1}>
|
};
|
||||||
{currentChapter?.[0]?.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography px="12px" pb={1}>
|
|
||||||
{ticksDisplay(value)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="flex flex-column video-osb-bubble">
|
|
||||||
<div
|
|
||||||
className="video-osd-trickplayBubble"
|
|
||||||
style={{
|
|
||||||
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
|
||||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
|
||||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
|
||||||
width: "100%",
|
|
||||||
aspectRatio: imageAspectRatio,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Typography variant="h6" px="12px" py={1}>
|
|
||||||
{ticksDisplay(value)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentChapter?.[0]?.Name) {
|
const chapterName = currentChapter?.[0]?.Name;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble">
|
<div
|
||||||
<Typography variant="h6" px="12px" pt={1}>
|
className="flex flex-column video-osb-bubble"
|
||||||
{currentChapter?.[0]?.Name}
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{trickplayStyle && (
|
||||||
|
<div className="video-osd-trickplayBubble" style={trickplayStyle} />
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: "8px 12px",
|
||||||
|
textAlign: "center",
|
||||||
|
width: "100%",
|
||||||
|
boxSizing: "border-box",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{chapterName && (
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
mb: 0.5,
|
||||||
|
color: "white",
|
||||||
|
textShadow: "0 2px 4px rgba(0,0,0,0.5)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{chapterName}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography px={2} pb={1}>
|
)}
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{
|
||||||
|
color: "rgba(255,255,255,0.9)",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
fontWeight: 500,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{ticksDisplay(value)}
|
{ticksDisplay(value)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="flex flex-column video-osb-bubble ">
|
|
||||||
<Typography variant="h6" px="12px" py={1}>
|
|
||||||
{ticksDisplay(value)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const virtualAnchorEl = useMemo(() => {
|
||||||
|
return {
|
||||||
|
getBoundingClientRect: () => {
|
||||||
|
return new DOMRect(
|
||||||
|
positionRef.current.x,
|
||||||
|
areaRef.current?.getBoundingClientRect().y ?? 0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
// title={sliderDisplayFormat(
|
// title={sliderDisplayFormat(
|
||||||
// positionRef.current.x - areaRef.current!.getBoundingClientRect().x,
|
// positionRef.current.x - areaRef.current!.getBoundingClientRect().x,
|
||||||
// )}
|
// )}
|
||||||
key={`${positionRef.current}`}
|
|
||||||
title={sliderDisplayFormat(hoverProgress)}
|
title={sliderDisplayFormat(hoverProgress)}
|
||||||
placement="top"
|
placement="top"
|
||||||
slotProps={{
|
slotProps={{
|
||||||
popper: {
|
popper: {
|
||||||
popperRef,
|
popperRef,
|
||||||
anchorEl: {
|
anchorEl: virtualAnchorEl,
|
||||||
getBoundingClientRect: () => {
|
|
||||||
return new DOMRect(
|
|
||||||
positionRef.current.x,
|
|
||||||
areaRef.current!.getBoundingClientRect().y,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// disablePortal: true,
|
// disablePortal: true,
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
// className: "glass",
|
className: "glass",
|
||||||
style: {
|
style: {
|
||||||
width: "34em",
|
width: "auto",
|
||||||
|
maxWidth: "none",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
padding: "12px",
|
padding: "0",
|
||||||
borderRadius: "20px",
|
borderRadius: "12px",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -16,16 +16,29 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 1em 2em;
|
padding: 2em 3em;
|
||||||
background: linear-gradient(to top, rgb(0 0 0 / 0.7) 5vh, transparent 26vh 90vh, rgb(0 0 0 / 0.7));
|
background: linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
rgba(0, 0, 0, 0.8) 0%,
|
||||||
|
rgba(0, 0, 0, 0) 25%,
|
||||||
|
rgba(0, 0, 0, 0) 75%,
|
||||||
|
rgba(0, 0, 0, 0.9) 100%
|
||||||
|
);
|
||||||
&.hovering {
|
&.hovering {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
&-controls {
|
&-controls {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1em;
|
||||||
|
|
||||||
&-timeline-text {
|
&-timeline-text {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
margin-top: 0.5em;
|
||||||
|
font-weight: 500;
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
&-progress {
|
&-progress {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -45,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
&-buttons {
|
&-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.4em;
|
gap: 0.5em;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||||
import { IconButton, 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 { motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, {
|
import React, {
|
||||||
type MouseEvent,
|
type MouseEvent,
|
||||||
useCallback,
|
useCallback,
|
||||||
@@ -30,7 +30,7 @@ import VideoPlayerSettingsMenu from "./settingsMenu";
|
|||||||
|
|
||||||
import "./controls.scss";
|
import "./controls.scss";
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
import { clearQueue } from "@/utils/store/queue";
|
||||||
import ProgressDislay from "./ProgressDisplay";
|
import ProgressDisplay from "./ProgressDisplay";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for the volume change interval when using the mouse wheel.
|
* Constant for the volume change interval when using the mouse wheel.
|
||||||
@@ -65,6 +65,7 @@ const VideoPlayerControls = ({
|
|||||||
// seekValue,
|
// seekValue,
|
||||||
isPlayerMuted,
|
isPlayerMuted,
|
||||||
volume,
|
volume,
|
||||||
|
setVolume,
|
||||||
toggleIsPlayerMuted,
|
toggleIsPlayerMuted,
|
||||||
increaseVolumeByStep,
|
increaseVolumeByStep,
|
||||||
decreaseVolumeByStep,
|
decreaseVolumeByStep,
|
||||||
@@ -86,6 +87,7 @@ const VideoPlayerControls = ({
|
|||||||
seekValue: state.playerState.seekValue,
|
seekValue: state.playerState.seekValue,
|
||||||
isPlayerMuted: state.playerState.isPlayerMuted,
|
isPlayerMuted: state.playerState.isPlayerMuted,
|
||||||
volume: state.playerState.volume,
|
volume: state.playerState.volume,
|
||||||
|
setVolume: state.setVolume,
|
||||||
toggleIsPlayerMuted: state.toggleIsPlayerMuted,
|
toggleIsPlayerMuted: state.toggleIsPlayerMuted,
|
||||||
increaseVolumeByStep: state.increaseVolumeByStep,
|
increaseVolumeByStep: state.increaseVolumeByStep,
|
||||||
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
||||||
@@ -115,6 +117,7 @@ const VideoPlayerControls = ({
|
|||||||
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
||||||
|
|
||||||
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
|
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
|
||||||
|
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
||||||
|
|
||||||
const [settingsMenuRef, setSettingsMenuRef] =
|
const [settingsMenuRef, setSettingsMenuRef] =
|
||||||
useState<HTMLButtonElement | null>(null);
|
useState<HTMLButtonElement | null>(null);
|
||||||
@@ -228,7 +231,7 @@ const VideoPlayerControls = ({
|
|||||||
<div className="video-player-osd-controls">
|
<div className="video-player-osd-controls">
|
||||||
<div className="video-player-osd-controls-timeline">
|
<div className="video-player-osd-controls-timeline">
|
||||||
<BubbleSlider />
|
<BubbleSlider />
|
||||||
<ProgressDislay />
|
<ProgressDisplay />
|
||||||
</div>
|
</div>
|
||||||
<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">
|
||||||
@@ -245,68 +248,41 @@ const VideoPlayerControls = ({
|
|||||||
|
|
||||||
<EndsAtDisplay />
|
<EndsAtDisplay />
|
||||||
</div>
|
</div>
|
||||||
<div className="video-player-osd-controls-buttons">
|
<div
|
||||||
{/* <motion.div
|
className="video-player-osd-controls-buttons"
|
||||||
style={{
|
|
||||||
width: "13em",
|
|
||||||
padding: "0.5em 1.5em",
|
|
||||||
paddingLeft: "0.8em",
|
|
||||||
gap: "0.4em",
|
|
||||||
background: "black",
|
|
||||||
borderRadius: "100px",
|
|
||||||
display: "grid",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
gridTemplateColumns: "2em 1fr",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
animate={{
|
|
||||||
opacity: showVolumeControl ? 1 : 0,
|
|
||||||
}}
|
|
||||||
whileHover={{
|
|
||||||
opacity: 1,
|
|
||||||
}}
|
|
||||||
onMouseLeave={() => setShowVolumeControl(false)}
|
onMouseLeave={() => setShowVolumeControl(false)}
|
||||||
>
|
>
|
||||||
<Typography textAlign="center">
|
<AnimatePresence>
|
||||||
{isPlayerMuted ? 0 : Math.round(playerVolume * 100)}
|
{showVolumeControl && (
|
||||||
</Typography>
|
<motion.div
|
||||||
<Slider
|
initial={{ width: 0, opacity: 0, marginRight: 0 }}
|
||||||
step={0.01}
|
animate={{ width: 100, opacity: 1, marginRight: 10 }}
|
||||||
max={1}
|
exit={{ width: 0, opacity: 0, marginRight: 0 }}
|
||||||
size="small"
|
style={{
|
||||||
value={isPlayerMuted ? 0 : playerVolume}
|
overflow: "hidden",
|
||||||
onChange={async (_, newValue) => {
|
display: "flex",
|
||||||
if (api && Array.isArray(newValue)) {
|
alignItems: "center",
|
||||||
dispatch({
|
|
||||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
|
||||||
payload: newValue[0],
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dispatch({
|
|
||||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
|
||||||
payload: newValue,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (newValue === 0)
|
|
||||||
dispatch({
|
|
||||||
type: VideoPlayerActionKind.SET_PLAYER_MUTED,
|
|
||||||
payload: true,
|
|
||||||
});
|
|
||||||
else
|
|
||||||
dispatch({
|
|
||||||
type: VideoPlayerActionKind.SET_PLAYER_MUTED,
|
|
||||||
payload: true,
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
<Slider
|
||||||
|
size="small"
|
||||||
|
value={isPlayerMuted ? 0 : volume}
|
||||||
|
max={1}
|
||||||
|
step={0.01}
|
||||||
|
onChange={(_, newValue) => {
|
||||||
|
const val = Array.isArray(newValue)
|
||||||
|
? newValue[0]
|
||||||
|
: newValue;
|
||||||
|
setVolume(val);
|
||||||
|
}}
|
||||||
|
sx={{ width: 100, color: "white" }}
|
||||||
/>
|
/>
|
||||||
</motion.div> */}
|
</motion.div>
|
||||||
{/* TODO: Volume menu */}
|
)}
|
||||||
|
</AnimatePresence>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={toggleIsPlayerMuted}
|
onClick={toggleIsPlayerMuted}
|
||||||
// onMouseMoveCapture={() => {
|
onMouseEnter={() => setShowVolumeControl(true)}
|
||||||
// setShowVolumeControl(true);
|
|
||||||
// }}
|
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">
|
<span className="material-symbols-rounded">
|
||||||
{isPlayerMuted
|
{isPlayerMuted
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { MenuItem, Popover, TextField } from "@mui/material";
|
import {
|
||||||
|
MenuItem,
|
||||||
|
Popover,
|
||||||
|
Switch,
|
||||||
|
TextField,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
import { toNumber } from "lodash";
|
import { toNumber } from "lodash";
|
||||||
import React, {
|
import React, {
|
||||||
type ChangeEventHandler,
|
type ChangeEventHandler,
|
||||||
@@ -29,10 +35,17 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
|
|
||||||
const api = useApiInContext((state) => state.api);
|
const api = useApiInContext((state) => state.api);
|
||||||
|
|
||||||
const { mediaSource, setIsBuffering } = usePlaybackStore(
|
const {
|
||||||
|
mediaSource,
|
||||||
|
setIsBuffering,
|
||||||
|
showStatsForNerds,
|
||||||
|
toggleShowStatsForNerds,
|
||||||
|
} = usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
mediaSource: state.mediaSource,
|
mediaSource: state.mediaSource,
|
||||||
setIsBuffering: state.setIsBuffering,
|
setIsBuffering: state.setIsBuffering,
|
||||||
|
showStatsForNerds: state.playerState.showStatsForNerds,
|
||||||
|
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -131,6 +144,10 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
|
<MenuItem onClick={toggleShowStatsForNerds}>
|
||||||
|
<Typography flexGrow={1}>Stats for Nerds</Typography>
|
||||||
|
<Switch checked={showStatsForNerds} />
|
||||||
|
</MenuItem>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ import pgsWorkerUrl from "libpgs/dist/libpgs.worker.js?url";
|
|||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import SkipSegmentButton from "@/components/playback/videoPlayer/buttons/SkipSegmentButton";
|
import SkipSegmentButton from "@/components/playback/videoPlayer/buttons/SkipSegmentButton";
|
||||||
import VideoPlayerControls from "@/components/playback/videoPlayer/controls";
|
import VideoPlayerControls from "@/components/playback/videoPlayer/controls";
|
||||||
|
import ErrorDisplay from "@/components/playback/videoPlayer/ErrorDisplay";
|
||||||
import LoadingIndicator from "@/components/playback/videoPlayer/LoadingIndicator";
|
import LoadingIndicator from "@/components/playback/videoPlayer/LoadingIndicator";
|
||||||
|
import StatsForNerds from "@/components/playback/videoPlayer/StatsForNerds";
|
||||||
import UpNextFlyout from "@/components/playback/videoPlayer/upNextFlyout";
|
import UpNextFlyout from "@/components/playback/videoPlayer/upNextFlyout";
|
||||||
import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay";
|
import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
@@ -150,6 +152,8 @@ export function VideoPlayer() {
|
|||||||
s.tracks,
|
s.tracks,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const [error, setError] = React.useState<any>(null);
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||||
useEffect(() => setBackdrop(""), []);
|
useEffect(() => setBackdrop(""), []);
|
||||||
|
|
||||||
@@ -217,12 +221,6 @@ export function VideoPlayer() {
|
|||||||
seekTo: (seconds: number) => {
|
seekTo: (seconds: number) => {
|
||||||
const internalPlayer = player.current;
|
const internalPlayer = player.current;
|
||||||
if (internalPlayer) {
|
if (internalPlayer) {
|
||||||
const current = internalPlayer.currentTime;
|
|
||||||
|
|
||||||
if (Math.abs(current - seconds) < 0.1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
internalPlayer.currentTime = seconds;
|
internalPlayer.currentTime = seconds;
|
||||||
console.log("Seeking to", seconds, "seconds");
|
console.log("Seeking to", seconds, "seconds");
|
||||||
} else {
|
} else {
|
||||||
@@ -232,7 +230,7 @@ export function VideoPlayer() {
|
|||||||
getCurrentTime: () => {
|
getCurrentTime: () => {
|
||||||
const internalPlayer = player.current;
|
const internalPlayer = player.current;
|
||||||
if (internalPlayer) {
|
if (internalPlayer) {
|
||||||
return internalPlayer.currentTime;
|
return internalPlayer.currentTime ?? 0;
|
||||||
}
|
}
|
||||||
console.warn("ReactPlayer is not ready yet");
|
console.warn("ReactPlayer is not ready yet");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -265,7 +263,8 @@ export function VideoPlayer() {
|
|||||||
const handleTimeUpdate = useCallback(async () => {
|
const handleTimeUpdate = useCallback(async () => {
|
||||||
if (!player.current) return;
|
if (!player.current) return;
|
||||||
|
|
||||||
const currentTime = player.current.currentTime;
|
const currentTime = player.current.currentTime ?? 0;
|
||||||
|
|
||||||
const ticks = secToTicks(currentTime);
|
const ticks = secToTicks(currentTime);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
@@ -318,6 +317,11 @@ export function VideoPlayer() {
|
|||||||
if (!api) {
|
if (!api) {
|
||||||
throw Error("API is not available, cannot report playback stopped.");
|
throw Error("API is not available, cannot report playback stopped.");
|
||||||
}
|
}
|
||||||
|
let currentTime = 0;
|
||||||
|
if (player.current) {
|
||||||
|
currentTime = player.current.currentTime ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Report Jellyfin server: Playback has ended/stopped
|
// Report Jellyfin server: Playback has ended/stopped
|
||||||
getPlaystateApi(api).reportPlaybackStopped({
|
getPlaystateApi(api).reportPlaybackStopped({
|
||||||
playbackStopInfo: {
|
playbackStopInfo: {
|
||||||
@@ -325,7 +329,7 @@ export function VideoPlayer() {
|
|||||||
ItemId: itemId,
|
ItemId: itemId,
|
||||||
MediaSourceId: mediaSource.id,
|
MediaSourceId: mediaSource.id,
|
||||||
PlaySessionId: playsessionId,
|
PlaySessionId: playsessionId,
|
||||||
PositionTicks: secToTicks(player.current?.currentTime ?? 0),
|
PositionTicks: secToTicks(currentTime),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
||||||
@@ -335,12 +339,20 @@ export function VideoPlayer() {
|
|||||||
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
||||||
if (player.current) {
|
if (player.current) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
const currentTime = player.current.currentTime ?? 0;
|
||||||
|
|
||||||
|
const seekTo = (time: number) => {
|
||||||
|
if (player.current) {
|
||||||
|
player.current.currentTime = time;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
player.current.currentTime += 10;
|
seekTo(currentTime + 10);
|
||||||
break;
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
player.current.currentTime -= 10;
|
seekTo(currentTime - 10);
|
||||||
break;
|
break;
|
||||||
case "F8":
|
case "F8":
|
||||||
case " ":
|
case " ":
|
||||||
@@ -516,6 +528,11 @@ export function VideoPlayer() {
|
|||||||
setIsBuffering(false);
|
setIsBuffering(false);
|
||||||
}, [setIsBuffering]);
|
}, [setIsBuffering]);
|
||||||
|
|
||||||
|
const handleError = useCallback((e: any) => {
|
||||||
|
console.error("Video playback error:", e);
|
||||||
|
setError(e);
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (!playbackStream) {
|
if (!playbackStream) {
|
||||||
return (
|
return (
|
||||||
<div className="video-player">
|
<div className="video-player">
|
||||||
@@ -540,6 +557,20 @@ export function VideoPlayer() {
|
|||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
>
|
>
|
||||||
<LoadingIndicator />
|
<LoadingIndicator />
|
||||||
|
<ErrorDisplay
|
||||||
|
error={error}
|
||||||
|
onExit={handleExitPlayer}
|
||||||
|
onRetry={() => {
|
||||||
|
setError(null);
|
||||||
|
if (player.current) {
|
||||||
|
// Try to reload the video
|
||||||
|
if (typeof player.current.load === "function") {
|
||||||
|
player.current.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<StatsForNerds playerRef={player as any} />
|
||||||
<VideoPlayerControls
|
<VideoPlayerControls
|
||||||
// isVisible={areControlsVisible}
|
// isVisible={areControlsVisible}
|
||||||
onHover={handleMouseMove}
|
onHover={handleMouseMove}
|
||||||
@@ -553,10 +584,10 @@ export function VideoPlayer() {
|
|||||||
key={playsessionId}
|
key={playsessionId}
|
||||||
playing={isPlayerPlaying}
|
playing={isPlayerPlaying}
|
||||||
src={playbackStream}
|
src={playbackStream}
|
||||||
ref={player as any}
|
ref={player}
|
||||||
onReady={handleReady}
|
onReady={handleReady}
|
||||||
onTimeUpdate={handleTimeUpdate}
|
onTimeUpdate={handleTimeUpdate}
|
||||||
// onError={handleError}
|
onError={handleError}
|
||||||
onEnded={handlePlaybackEnded}
|
onEnded={handlePlaybackEnded}
|
||||||
width="100vw"
|
width="100vw"
|
||||||
height="100vh"
|
height="100vh"
|
||||||
|
|||||||
@@ -292,8 +292,10 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.glass {
|
.glass {
|
||||||
background: rgb(0 0 0 / 0.3) !important;
|
background: rgba(0, 0, 0, 0.6) !important;
|
||||||
backdrop-filter: blur(40px);
|
backdrop-filter: blur(20px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
|
||||||
}
|
}
|
||||||
|
|
||||||
.opacity-07{
|
.opacity-07{
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ type PlaybackStoreState = {
|
|||||||
id: string | undefined;
|
id: string | undefined;
|
||||||
subtitle: subtitlePlaybackInfo;
|
subtitle: subtitlePlaybackInfo;
|
||||||
audio: audioPlaybackInfo;
|
audio: audioPlaybackInfo;
|
||||||
|
bitrate?: number;
|
||||||
|
videoCodec?: string;
|
||||||
|
audioCodec?: string;
|
||||||
|
isDirectPlay?: boolean;
|
||||||
|
transcodingUrl?: string;
|
||||||
};
|
};
|
||||||
playbackStream: string;
|
playbackStream: string;
|
||||||
playsessionId: string | undefined | null;
|
playsessionId: string | undefined | null;
|
||||||
@@ -93,6 +98,10 @@ type PlaybackStoreState = {
|
|||||||
* This should be set to true when the player is buffering
|
* This should be set to true when the player is buffering
|
||||||
*/
|
*/
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
/**
|
||||||
|
* Used to show the stats for nerds dialog
|
||||||
|
*/
|
||||||
|
showStatsForNerds: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Index of the next segment to be played
|
* Index of the next segment to be played
|
||||||
@@ -198,6 +207,10 @@ type PlaybackStoreActions = {
|
|||||||
* This should be set to false when the player has finished loading
|
* This should be set to false when the player has finished loading
|
||||||
*/
|
*/
|
||||||
setIsLoading: (isLoading: boolean) => void;
|
setIsLoading: (isLoading: boolean) => void;
|
||||||
|
/**
|
||||||
|
* Toggle the stats for nerds dialog
|
||||||
|
*/
|
||||||
|
toggleShowStatsForNerds: () => void;
|
||||||
setPlayerState: (playerState: PlaybackStoreState["playerState"]) => void;
|
setPlayerState: (playerState: PlaybackStoreState["playerState"]) => void;
|
||||||
|
|
||||||
// Playback information related actions
|
// Playback information related actions
|
||||||
@@ -288,6 +301,7 @@ export const usePlaybackStore = create<
|
|||||||
isUserSeeking: false,
|
isUserSeeking: false,
|
||||||
seekValue: 0,
|
seekValue: 0,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
|
showStatsForNerds: false,
|
||||||
},
|
},
|
||||||
userId: undefined!,
|
userId: undefined!,
|
||||||
// -- MediaSegment skip feature --
|
// -- MediaSegment skip feature --
|
||||||
@@ -399,6 +413,11 @@ export const usePlaybackStore = create<
|
|||||||
id: string | undefined,
|
id: string | undefined,
|
||||||
subtitle: subtitlePlaybackInfo,
|
subtitle: subtitlePlaybackInfo,
|
||||||
audio: audioPlaybackInfo,
|
audio: audioPlaybackInfo,
|
||||||
|
bitrate?: number,
|
||||||
|
videoCodec?: string,
|
||||||
|
audioCodec?: string,
|
||||||
|
isDirectPlay?: boolean,
|
||||||
|
transcodingUrl?: string,
|
||||||
) =>
|
) =>
|
||||||
set((state) => {
|
set((state) => {
|
||||||
state.mediaSource.videoTrack = videoTrack;
|
state.mediaSource.videoTrack = videoTrack;
|
||||||
@@ -407,6 +426,11 @@ export const usePlaybackStore = create<
|
|||||||
state.mediaSource.id = id;
|
state.mediaSource.id = id;
|
||||||
state.mediaSource.subtitle = subtitle;
|
state.mediaSource.subtitle = subtitle;
|
||||||
state.mediaSource.audio = audio;
|
state.mediaSource.audio = audio;
|
||||||
|
state.mediaSource.bitrate = bitrate;
|
||||||
|
state.mediaSource.videoCodec = videoCodec;
|
||||||
|
state.mediaSource.audioCodec = audioCodec;
|
||||||
|
state.mediaSource.isDirectPlay = isDirectPlay;
|
||||||
|
state.mediaSource.transcodingUrl = transcodingUrl;
|
||||||
}),
|
}),
|
||||||
setPlaybackStream: (playbackStream: string) =>
|
setPlaybackStream: (playbackStream: string) =>
|
||||||
set((state) => {
|
set((state) => {
|
||||||
@@ -445,6 +469,11 @@ export const usePlaybackStore = create<
|
|||||||
set((state) => {
|
set((state) => {
|
||||||
state.playerState.isLoading = isLoading;
|
state.playerState.isLoading = isLoading;
|
||||||
}),
|
}),
|
||||||
|
toggleShowStatsForNerds: () =>
|
||||||
|
set((state) => {
|
||||||
|
state.playerState.showStatsForNerds =
|
||||||
|
!state.playerState.showStatsForNerds;
|
||||||
|
}),
|
||||||
setPlayerState: (playerState) =>
|
setPlayerState: (playerState) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
...state,
|
...state,
|
||||||
@@ -783,6 +812,8 @@ export const playItemFromQueue = async (
|
|||||||
(value) => value.Type === "Video",
|
(value) => value.Type === "Video",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isDirectPlay = !source.SupportsTranscoding || !source.TranscodingUrl;
|
||||||
|
|
||||||
playItem({
|
playItem({
|
||||||
metadata: {
|
metadata: {
|
||||||
itemName,
|
itemName,
|
||||||
@@ -809,6 +840,11 @@ export const playItemFromQueue = async (
|
|||||||
enable: subtitle?.enable ?? false,
|
enable: subtitle?.enable ?? false,
|
||||||
},
|
},
|
||||||
audio: audio,
|
audio: audio,
|
||||||
|
bitrate: source.Bitrate,
|
||||||
|
videoCodec: videoTrack?.[0]?.Codec,
|
||||||
|
audioCodec: audio.allTracks?.find((t) => t.Index === audio.track)?.Codec,
|
||||||
|
isDirectPlay: isDirectPlay,
|
||||||
|
transcodingUrl: source.TranscodingUrl,
|
||||||
},
|
},
|
||||||
playbackStream: playbackUrl,
|
playbackStream: playbackUrl,
|
||||||
playsessionId: mediaSource.PlaySessionId,
|
playsessionId: mediaSource.PlaySessionId,
|
||||||
|
|||||||
Reference in new issue
Block a user