Round Video: Fix failing to play
This commit is contained in:
parent
8cbf312268
commit
a29e6c07da
@ -38,17 +38,7 @@ type OwnProps = {
|
|||||||
isDownloading?: boolean;
|
isDownloading?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
let currentOnRelease: NoneToVoidFunction;
|
let stopPrevious: NoneToVoidFunction;
|
||||||
|
|
||||||
function createCapture(onRelease: NoneToVoidFunction) {
|
|
||||||
return () => {
|
|
||||||
if (currentOnRelease) {
|
|
||||||
currentOnRelease();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentOnRelease = onRelease;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const RoundVideo: FC<OwnProps> = ({
|
const RoundVideo: FC<OwnProps> = ({
|
||||||
message,
|
message,
|
||||||
@ -130,17 +120,24 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const shouldPlay = Boolean(mediaData && isIntersecting);
|
const shouldPlay = Boolean(mediaData && isIntersecting);
|
||||||
|
|
||||||
const stopPlaying = () => {
|
const stopPlaying = useCallback(() => {
|
||||||
|
if (!playerRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsActivated(false);
|
setIsActivated(false);
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
safePlay(playerRef.current!);
|
safePlay(playerRef.current);
|
||||||
|
|
||||||
fastRaf(() => {
|
fastRaf(() => {
|
||||||
playingProgressRef.current!.innerHTML = '';
|
playingProgressRef.current!.innerHTML = '';
|
||||||
});
|
});
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const capturePlaying = createCapture(stopPlaying);
|
const capturePlaying = useCallback(() => {
|
||||||
|
stopPrevious?.();
|
||||||
|
stopPrevious = stopPlaying;
|
||||||
|
}, [stopPlaying]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!playerRef.current) {
|
if (!playerRef.current) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user