fix(player): remove dialogue barcode from timeline
Continuous Integration / build_web (push) Failing after 0s
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 0s
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
Keep the rail clean: chapter ticks and segment colours stay, the dense dialogue marks are gone.
This commit is contained in:
1 parent
56594ad526
commit
a390df82e9
2 files changed
+2
-90
No files matched your search
@@ -4,7 +4,6 @@ import type {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Slider, Tooltip, Typography } from "@mui/material";
|
||||
import type { Instance } from "@popperjs/core";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, {
|
||||
type MouseEvent,
|
||||
useCallback,
|
||||
@@ -27,30 +26,6 @@ const SEGMENT_LABELS: Record<string, string> = {
|
||||
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 time = Math.round(ticks / 10000);
|
||||
let formatedTime = "";
|
||||
@@ -160,45 +135,6 @@ const BubbleSlider = () => {
|
||||
[itemDuration],
|
||||
);
|
||||
|
||||
const dialogueTrack = useMemo(() => {
|
||||
const tracks = mediaSource.subtitle?.allTracks ?? [];
|
||||
return (
|
||||
tracks.find(
|
||||
(track) =>
|
||||
track.Index === mediaSource.subtitle?.track &&
|
||||
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 segmentGradient = useMemo(() => {
|
||||
if (!itemDuration) return undefined;
|
||||
const colors: Record<string, string> = {
|
||||
@@ -407,20 +343,6 @@ const BubbleSlider = () => {
|
||||
>
|
||||
<div className="video-player-timeline">
|
||||
<div className="video-player-timeline-track" aria-hidden="true">
|
||||
{dialogueBuckets?.map((density, index) =>
|
||||
density > 0 ? (
|
||||
<span
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: fixed density buckets
|
||||
key={`dialogue-${index}`}
|
||||
className="video-player-timeline-dialogue"
|
||||
style={{
|
||||
left: `${(index / dialogueBuckets.length) * 100}%`,
|
||||
height: `${Math.max(2, density * 8)}px`,
|
||||
opacity: 0.25 + density * 0.55,
|
||||
}}
|
||||
/>
|
||||
) : null,
|
||||
)}
|
||||
{itemChapters?.map((chapter, index) => (
|
||||
<span
|
||||
key={`chapter-${chapter.StartPositionTicks ?? index}`}
|
||||
|
||||
Reference in new issue
Block a user