about summary refs log tree commit diff
path: root/src/view/com/util/post-embeds
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/com/util/post-embeds')
-rw-r--r--src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx15
-rw-r--r--src/view/com/util/post-embeds/VideoEmbed.tsx2
-rw-r--r--src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx4
3 files changed, 18 insertions, 3 deletions
diff --git a/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx b/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx
index da8c7a98c..95fa0bb0e 100644
--- a/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx
+++ b/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx
@@ -1,7 +1,7 @@
 import React from 'react'
 import {useVideoPlayer, VideoPlayer} from 'expo-video'
 
-import {isNative} from '#/platform/detection'
+import {isAndroid, isNative} from '#/platform/detection'
 
 const Context = React.createContext<{
   activeSource: string
@@ -26,7 +26,18 @@ export function Provider({children}: {children: React.ReactNode}) {
   })
 
   const setActiveSourceOuter = (src: string | null, viewId: string | null) => {
-    setActiveSource(src ? src : '')
+    // HACK
+    // expo-video doesn't like it when you try and move a `player` to another `VideoView`. Instead, we need to actually
+    // unregister that player to let the new screen register it. This is only a problem on Android, so we only need to
+    // apply it there.
+    if (src === activeSource && isAndroid) {
+      setActiveSource('')
+      setTimeout(() => {
+        setActiveSource(src ? src : '')
+      }, 100)
+    } else {
+      setActiveSource(src ? src : '')
+    }
     setActiveViewId(viewId ? viewId : '')
   }
 
diff --git a/src/view/com/util/post-embeds/VideoEmbed.tsx b/src/view/com/util/post-embeds/VideoEmbed.tsx
index e5457555b..9c3a34dda 100644
--- a/src/view/com/util/post-embeds/VideoEmbed.tsx
+++ b/src/view/com/util/post-embeds/VideoEmbed.tsx
@@ -71,7 +71,7 @@ function InnerWrapper({embed}: Props) {
 
   const [playerStatus, setPlayerStatus] = useState<
     VideoPlayerStatus | 'paused'
-  >(player.playing ? 'readyToPlay' : 'paused')
+  >('paused')
   const [isMuted, setIsMuted] = useState(player.muted)
   const [isFullscreen, setIsFullscreen] = React.useState(false)
   const [timeRemaining, setTimeRemaining] = React.useState(0)
diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
index 31e863038..de9a2c74c 100644
--- a/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
+++ b/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
@@ -8,6 +8,7 @@ import {useLingui} from '@lingui/react'
 
 import {HITSLOP_30} from '#/lib/constants'
 import {clamp} from '#/lib/numbers'
+import {isAndroid} from 'platform/detection'
 import {useActiveVideoNative} from 'view/com/util/post-embeds/ActiveVideoNativeContext'
 import {atoms as a, useTheme} from '#/alf'
 import {Mute_Stroke2_Corner0_Rounded as MuteIcon} from '#/components/icons/Mute'
@@ -61,6 +62,9 @@ export function VideoEmbedInnerNative({
           PlatformInfo.setAudioActive(true)
           player.muted = false
           setIsFullscreen(true)
+          if (isAndroid) {
+            player.play()
+          }
         }}
         onFullscreenExit={() => {
           PlatformInfo.setAudioCategory(AudioCategory.Ambient)