fix negative audio duration info crash react-range

This commit is contained in:
Ajay Bura 2024-04-24 08:05:13 +05:30
parent 689adde8ae
commit 3f08f75aab

View file

@ -45,7 +45,8 @@ export const AudioContent = as<'div', AudioContentProps>(
const [currentTime, setCurrentTime] = useState(0);
// duration in seconds. (NOTE: info.duration is in milliseconds)
const [duration, setDuration] = useState((info.duration ?? 0) / 1000);
const infoDuration = info.duration ?? 0;
const [duration, setDuration] = useState((infoDuration >= 0 ? infoDuration : 0) / 1000);
const getAudioRef = useCallback(() => audioRef.current, []);
const { loading } = useMediaLoading(getAudioRef);