diff --git a/src/view/com/util/post-embeds/VideoEmbedInner.web.tsx b/src/view/com/util/post-embeds/VideoEmbedInner.web.tsx index cd73ffc055..04b38fdcf0 100644 --- a/src/view/com/util/post-embeds/VideoEmbedInner.web.tsx +++ b/src/view/com/util/post-embeds/VideoEmbedInner.web.tsx @@ -113,15 +113,6 @@ export function VideoPlayer({ } }, [source, hls]) - // use minimal quality when not active - useEffect(() => { - if (active) { - hls.nextLevel = -1 - } else { - hls.nextLevel = 0 - } - }, [hls, active]) - const enterFullscreen = useCallback(() => { if (containerRef.current) { containerRef.current.requestFullscreen() @@ -151,6 +142,7 @@ export function VideoPlayer({ /> + hls: Hls active: boolean setActive: () => void focused: boolean diff --git a/src/view/com/util/post-embeds/VideoWebControls.web.tsx b/src/view/com/util/post-embeds/VideoWebControls.web.tsx index f5d40878ac..336b080dfd 100644 --- a/src/view/com/util/post-embeds/VideoWebControls.web.tsx +++ b/src/view/com/util/post-embeds/VideoWebControls.web.tsx @@ -3,6 +3,7 @@ import {Pressable, View} from 'react-native' import Animated, {FadeIn, FadeOut} from 'react-native-reanimated' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import type Hls from 'hls.js' import { useAutoplayDisabled, @@ -29,6 +30,7 @@ import {Text} from '#/components/Typography' export function Controls({ videoRef, + hls, active, setActive, focused, @@ -37,6 +39,7 @@ export function Controls({ enterFullscreen, }: { videoRef: React.RefObject + hls: Hls active: boolean setActive: () => void focused: boolean @@ -104,6 +107,16 @@ export function Controls({ } }, [onScreen, pause, active, play, autoplayDisabled]) + // use minimal quality when not focused + useEffect(() => { + if (focused) { + // auto decide quality based on network conditions + hls.nextLevel = -1 + } else { + hls.nextLevel = 0 + } + }, [hls, focused]) + // clicking on any button should focus the player, if it's not already focused const drawFocus = useCallback(() => { if (!active) {