|
|
|
@ -11,7 +11,12 @@ export interface IAudioPlayerRef {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default forwardRef(function AudioPlayer(
|
|
|
|
|
{ src, autoPlay, onEnded }: { src?: string; autoPlay?: boolean; onEnded?: () => void },
|
|
|
|
|
{
|
|
|
|
|
src,
|
|
|
|
|
autoPlay,
|
|
|
|
|
onEnded,
|
|
|
|
|
onSlideEnd,
|
|
|
|
|
}: { src?: string; autoPlay?: boolean; onEnded?: () => void; onSlideEnd?: () => void },
|
|
|
|
|
ref: React.Ref<IAudioPlayerRef>,
|
|
|
|
|
) {
|
|
|
|
|
const [curTime, setCurTime] = useState('00:00');
|
|
|
|
@ -56,8 +61,10 @@ export default forwardRef(function AudioPlayer(
|
|
|
|
|
const handleSlideEnd = () => {
|
|
|
|
|
if (audioRef?.current) {
|
|
|
|
|
audioRef.current.currentTime = Number(sliderRef?.current?.value || 0);
|
|
|
|
|
audioRef.current.play();
|
|
|
|
|
}
|
|
|
|
|
isDragingRef.current = false;
|
|
|
|
|
onSlideEnd?.();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSlideChange = () => requestAnimationFrame(() => setSliderBgSize());
|
|
|
|
|