import { useTrickplay } from '@/hooks/useTrickplay'; import { formatTimeString, msToTicks, ticksToSeconds } from '@/utils/time'; import React, { useRef, useState } from 'react'; import { View, Text } from 'react-native'; import { Image } from "expo-image"; import { Slider } from "react-native-awesome-slider"; import { SharedValue, useSharedValue } from 'react-native-reanimated'; import { BaseItemDto } from '@jellyfin/sdk/lib/generated-client'; interface SliderScrubberProps { cacheProgress: SharedValue; handleSliderStart: () => void; handleSliderComplete: (value: number) => void; progress: SharedValue; min: SharedValue; max: SharedValue; currentTime: number; remainingTime: number; item: BaseItemDto; } const SliderScrubber: React.FC = ({ cacheProgress, handleSliderStart, handleSliderComplete, progress, min, max, currentTime, remainingTime, item, }) => { const [time, setTime] = useState({ hours: 0, minutes: 0, seconds: 0 }); const { trickPlayUrl, calculateTrickplayUrl, trickplayInfo } = useTrickplay( item, ); const handleSliderChange = (value: number) => { const progressInTicks = msToTicks(value); calculateTrickplayUrl(progressInTicks); const progressInSeconds = Math.floor(ticksToSeconds(progressInTicks)); const hours = Math.floor(progressInSeconds / 3600); const minutes = Math.floor((progressInSeconds % 3600) / 60); const seconds = progressInSeconds % 60; setTime({ hours, minutes, seconds }); }; return ( { if (!trickPlayUrl || !trickplayInfo) { return null; } const { x, y, url } = trickPlayUrl; const tileWidth = 150; const tileHeight = 150 / trickplayInfo.aspectRatio!; return ( {`${time.hours > 0 ? `${time.hours}:` : ""}${ time.minutes < 10 ? `0${time.minutes}` : time.minutes }:${ time.seconds < 10 ? `0${time.seconds}` : time.seconds }`} ); }} sliderHeight={10} thumbWidth={0} progress={progress} minimumValue={min} maximumValue={max} /> {formatTimeString(currentTime, "ms")} -{formatTimeString(remainingTime, "ms")} ); }; export default SliderScrubber;