disable findAndActivateVideo on native

This commit is contained in:
Samuel Newman
2024-07-05 17:22:47 +01:00
parent cec2438f6a
commit f0aa636762
2 changed files with 8 additions and 1 deletions
@@ -8,6 +8,7 @@ import React, {
} from 'react'
import {useWindowDimensions} from 'react-native'
import {isNative} from '#/platform/detection'
import {VideoPlayerProvider} from './VideoPlayerContext'
const ActiveVideoContext = React.createContext<{
@@ -28,6 +29,8 @@ export function ActiveVideoProvider({children}: {children: React.ReactNode}) {
const measurementCallbacks = useRef<Record<string, () => DOMRect | void>>({})
useEffect(() => {
if (isNative) return
const findAndActivateVideo = () => {
if (Object.keys(measurementCallbacks.current).length === 0) {
return
@@ -22,7 +22,11 @@ export function VideoPlayerProvider({
// make sure we're playing every time the viewId changes
// this means the video is different
useEffect(() => {
player.play()
if (viewId === null) {
player.pause()
} else {
player.play()
}
}, [viewId, player])
return (