Optimized Video: Fix priority video pausing (#4454)
This commit is contained in:
parent
b69e2b8d0f
commit
38ca3dd9de
@ -151,7 +151,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
stopPrevious = stopPlaying;
|
stopPrevious = stopPlaying;
|
||||||
});
|
});
|
||||||
|
|
||||||
const tooglePlaying = useLastCallback(() => {
|
const togglePlaying = useLastCallback(() => {
|
||||||
const playerEl = playerRef.current!;
|
const playerEl = playerRef.current!;
|
||||||
if (isActivated) {
|
if (isActivated) {
|
||||||
if (playerEl.paused) {
|
if (playerEl.paused) {
|
||||||
@ -175,7 +175,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
if (!isInOneTimeModal) {
|
if (!isInOneTimeModal) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tooglePlaying();
|
togglePlaying();
|
||||||
}, [isInOneTimeModal]);
|
}, [isInOneTimeModal]);
|
||||||
|
|
||||||
const handleClick = useLastCallback(() => {
|
const handleClick = useLastCallback(() => {
|
||||||
@ -196,7 +196,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tooglePlaying();
|
togglePlaying();
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleTimeUpdate = useLastCallback((e: React.UIEvent<HTMLVideoElement>) => {
|
const handleTimeUpdate = useLastCallback((e: React.UIEvent<HTMLVideoElement>) => {
|
||||||
@ -250,6 +250,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
muted={!isActivated}
|
muted={!isActivated}
|
||||||
loop={!isActivated}
|
loop={!isActivated}
|
||||||
playsInline
|
playsInline
|
||||||
|
isPriority
|
||||||
onEnded={isActivated ? onStop ?? stopPlaying : undefined}
|
onEnded={isActivated ? onStop ?? stopPlaying : undefined}
|
||||||
onTimeUpdate={isActivated ? handleTimeUpdate : undefined}
|
onTimeUpdate={isActivated ? handleTimeUpdate : undefined}
|
||||||
onReady={markPlayerReady}
|
onReady={markPlayerReady}
|
||||||
|
|||||||
@ -25,9 +25,9 @@ export default function useVideoAutoPause(
|
|||||||
requestMeasure(unfreezePlaying);
|
requestMeasure(unfreezePlaying);
|
||||||
});
|
});
|
||||||
|
|
||||||
useBackgroundMode(pause, unfreezePlayingOnRaf, !canPlay);
|
useBackgroundMode(pause, unfreezePlayingOnRaf, !canPlay || isPriority);
|
||||||
useHeavyAnimationCheck(pause, unfreezePlaying, !canPlay);
|
useHeavyAnimationCheck(pause, unfreezePlaying, !canPlay || isPriority);
|
||||||
usePriorityPlaybackCheck(pause, unfreezePlaying, !canPlay);
|
usePriorityPlaybackCheck(pause, unfreezePlaying, !canPlay || isPriority);
|
||||||
|
|
||||||
const handlePlaying = useLastCallback(() => {
|
const handlePlaying = useLastCallback(() => {
|
||||||
if (!canPlayRef.current || (!isPriority && isFrozen())) {
|
if (!canPlayRef.current || (!isPriority && isFrozen())) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user