mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
Merge pull request #351 from tapframe/revert-347-feature/improved10secSkipAndRewind
Revert "patch: incremental 10 sec skip/rewind on multiple taps"
This commit is contained in:
commit
5b2c57d5c7
2 changed files with 1 additions and 48 deletions
|
|
@ -1,33 +0,0 @@
|
||||||
import { useCallback, useRef, useEffect } from 'react';
|
|
||||||
|
|
||||||
export function useDebounceCallback<T extends (...args: any[]) => void>(
|
|
||||||
callback: T,
|
|
||||||
delay: number
|
|
||||||
) {
|
|
||||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
||||||
const callbackRef = useRef(callback);
|
|
||||||
|
|
||||||
// Sync latest callback to avoid stale closures
|
|
||||||
useEffect(() => {
|
|
||||||
callbackRef.current = callback;
|
|
||||||
}, [callback]);
|
|
||||||
|
|
||||||
const debouncedFunction = useCallback(
|
|
||||||
(...args: Parameters<T>) => {
|
|
||||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
||||||
timeoutRef.current = setTimeout(() => {
|
|
||||||
callbackRef.current(...args);
|
|
||||||
}, delay);
|
|
||||||
},
|
|
||||||
[delay]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cleanup on unmount to prevent memory leaks
|
|
||||||
useEffect(() => {
|
|
||||||
return () => {
|
|
||||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return debouncedFunction;
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,6 @@ import Slider from '@react-native-community/slider';
|
||||||
import { styles } from '../utils/playerStyles'; // Updated styles
|
import { styles } from '../utils/playerStyles'; // Updated styles
|
||||||
import { getTrackDisplayName } from '../utils/playerUtils';
|
import { getTrackDisplayName } from '../utils/playerUtils';
|
||||||
import { useTheme } from '../../../contexts/ThemeContext';
|
import { useTheme } from '../../../contexts/ThemeContext';
|
||||||
import { useDebounceCallback } from '../android/hooks/useDebounceCallback';
|
|
||||||
|
|
||||||
interface PlayerControlsProps {
|
interface PlayerControlsProps {
|
||||||
showControls: boolean;
|
showControls: boolean;
|
||||||
|
|
@ -135,15 +134,6 @@ export const PlayerControls: React.FC<PlayerControlsProps> = ({
|
||||||
const playIconOpacity = React.useRef(new Animated.Value(1)).current;
|
const playIconOpacity = React.useRef(new Animated.Value(1)).current;
|
||||||
|
|
||||||
/* Handle Seek with Animation */
|
/* Handle Seek with Animation */
|
||||||
const [skipRewindSeconds, setSkipRewindSeconds] = React.useState(0);
|
|
||||||
const finalSkipRewind = (finalValue: number) => {
|
|
||||||
console.log(`Final value processed: ${finalValue}`);
|
|
||||||
skip(finalValue);
|
|
||||||
setSkipRewindSeconds(0);
|
|
||||||
}
|
|
||||||
const debouncedSkip = useDebounceCallback((val: number) => {
|
|
||||||
finalSkipRewind(val);
|
|
||||||
}, 800);
|
|
||||||
const handleSeekWithAnimation = (seconds: number) => {
|
const handleSeekWithAnimation = (seconds: number) => {
|
||||||
const isForward = seconds > 0;
|
const isForward = seconds > 0;
|
||||||
|
|
||||||
|
|
@ -222,11 +212,7 @@ export const PlayerControls: React.FC<PlayerControlsProps> = ({
|
||||||
arcRotation.setValue(0);
|
arcRotation.setValue(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
setSkipRewindSeconds(prev => {
|
skip(seconds);
|
||||||
const nextVal = prev + seconds;
|
|
||||||
debouncedSkip(nextVal);
|
|
||||||
return nextVal;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Handle Play/Pause with Animation */
|
/* Handle Play/Pause with Animation */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue