diff --git a/src/components/playback/videoPlayer/bubbleSlider/index.tsx b/src/components/playback/videoPlayer/bubbleSlider/index.tsx index 67ef4c7..f152c9a 100644 --- a/src/components/playback/videoPlayer/bubbleSlider/index.tsx +++ b/src/components/playback/videoPlayer/bubbleSlider/index.tsx @@ -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 = { 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 = { @@ -407,20 +343,6 @@ const BubbleSlider = () => { >