diff options
author | Hailey <me@haileyok.com> | 2024-09-13 12:44:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-13 12:44:42 -0700 |
commit | 26508cfe6a89df4ae1ab1256753faa860597bbc8 (patch) | |
tree | 8f0bf4e8f65863ddbe8d1ede7df3fd342e6ab69b /src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx | |
parent | 78a531f5ffe9287b5384ec1649dfbc45435ced28 (diff) | |
download | voidsky-26508cfe6a89df4ae1ab1256753faa860597bbc8.tar.zst |
[Video] Remove `expo-video`, use `bluesky-video` (#5282)
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx b/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx deleted file mode 100644 index 95fa0bb0e..000000000 --- a/src/view/com/util/post-embeds/ActiveVideoNativeContext.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import React from 'react' -import {useVideoPlayer, VideoPlayer} from 'expo-video' - -import {isAndroid, isNative} from '#/platform/detection' - -const Context = React.createContext<{ - activeSource: string - activeViewId: string | undefined - setActiveSource: (src: string | null, viewId: string | null) => void - player: VideoPlayer -} | null>(null) - -export function Provider({children}: {children: React.ReactNode}) { - if (!isNative) { - throw new Error('ActiveVideoProvider may only be used on native.') - } - - const [activeSource, setActiveSource] = React.useState('') - const [activeViewId, setActiveViewId] = React.useState<string>() - - const player = useVideoPlayer(activeSource, p => { - p.muted = true - p.loop = true - // We want to immediately call `play` so we get the loading state - p.play() - }) - - const setActiveSourceOuter = (src: string | null, viewId: string | null) => { - // 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 : '') - } - - return ( - <Context.Provider - value={{ - activeSource, - setActiveSource: setActiveSourceOuter, - activeViewId, - player, - }}> - {children} - </Context.Provider> - ) -} - -export function useActiveVideoNative() { - const context = React.useContext(Context) - if (!context) { - throw new Error( - 'useActiveVideoNative must be used within a ActiveVideoNativeProvider', - ) - } - return context -} |