From 6eabedd037e6631eef4be5302b25e6cdba18f126 Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 5 Sep 2024 14:54:09 -0700 Subject: [PATCH] [Video] More adjustments for loading state jank (#5171) --- src/view/com/util/post-embeds/VideoEmbed.tsx | 90 ++++++++++---------- yarn.lock | 2 +- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/view/com/util/post-embeds/VideoEmbed.tsx b/src/view/com/util/post-embeds/VideoEmbed.tsx index 2dafce7b..7db25b4d 100644 --- a/src/view/com/util/post-embeds/VideoEmbed.tsx +++ b/src/view/com/util/post-embeds/VideoEmbed.tsx @@ -68,7 +68,9 @@ function InnerWrapper({embed}: Props) { useActiveVideoNative() const viewId = useId() - const [playerStatus, setPlayerStatus] = useState('loading') + const [playerStatus, setPlayerStatus] = useState< + VideoPlayerStatus | 'switching' + >('loading') const [isMuted, setIsMuted] = useState(player.muted) const [isFullscreen, setIsFullscreen] = React.useState(false) const [timeRemaining, setTimeRemaining] = React.useState(0) @@ -77,6 +79,8 @@ function InnerWrapper({embed}: Props) { isActive && (playerStatus === 'waitingToPlayAtSpecifiedRate' || playerStatus === 'loading') + const isSwitching = playerStatus === 'switching' + const showOverlay = !isActive || isLoading || isSwitching // send error up to error boundary const [error, setError] = useState(null) @@ -130,6 +134,7 @@ function InnerWrapper({embed}: Props) { player.play() } } else { + setPlayerStatus('switching') player.muted = true if (player.playing) { player.pause() @@ -148,48 +153,47 @@ function InnerWrapper({embed}: Props) { setIsFullscreen={setIsFullscreen} /> ) : null} - {!isActive || isLoading ? ( - - {embed.alt} - - - ) : null} + + {embed.alt} + + ) } diff --git a/yarn.lock b/yarn.lock index 3333e220..cc233060 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12416,7 +12416,7 @@ expo-updates@~0.25.14: "expo-video@https://github.com/bluesky-social/expo/raw/expo-video-1.2.4-patch/packages/expo-video/expo-video-v1.2.4.tgz": version "1.2.4" - resolved "https://github.com/bluesky-social/expo/raw/expo-video-1.2.4-patch/packages/expo-video/expo-video-v1.2.4.tgz#584c17e34f59cb018eed2f4f408b6c94e2a1910f" + resolved "https://github.com/bluesky-social/expo/raw/expo-video-1.2.4-patch/packages/expo-video/expo-video-v1.2.4.tgz#15af07368c72cb847124be9922d5c7a3fe4293a4" expo-web-browser@~13.0.3: version "13.0.3"