Round Video: Fix failing to play

This commit is contained in:
Alexander Zinchuk 2022-02-14 00:53:34 +03:00
parent 8cbf312268
commit a29e6c07da

View File

@ -38,17 +38,7 @@ type OwnProps = {
isDownloading?: boolean;
};
let currentOnRelease: NoneToVoidFunction;
function createCapture(onRelease: NoneToVoidFunction) {
return () => {
if (currentOnRelease) {
currentOnRelease();
}
currentOnRelease = onRelease;
};
}
let stopPrevious: NoneToVoidFunction;
const RoundVideo: FC<OwnProps> = ({
message,
@ -130,17 +120,24 @@ const RoundVideo: FC<OwnProps> = ({
const shouldPlay = Boolean(mediaData && isIntersecting);
const stopPlaying = () => {
const stopPlaying = useCallback(() => {
if (!playerRef.current) {
return;
}
setIsActivated(false);
setProgress(0);
safePlay(playerRef.current!);
safePlay(playerRef.current);
fastRaf(() => {
playingProgressRef.current!.innerHTML = '';
});
};
}, []);
const capturePlaying = createCapture(stopPlaying);
const capturePlaying = useCallback(() => {
stopPrevious?.();
stopPrevious = stopPlaying;
}, [stopPlaying]);
useEffect(() => {
if (!playerRef.current) {