[Video] Toggle controls when entering fullscreen (#5113)

zio/stable
Hailey 2024-09-03 11:04:46 -07:00 committed by GitHub
parent 5d300bec90
commit 7f26ad508e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -26,6 +26,7 @@ export function VideoEmbedInnerNative({
const {_} = useLingui()
const {player} = useActiveVideoNative()
const ref = useRef<VideoView>(null)
const [isFullscreen, setIsFullscreen] = useState(false)
const enterFullscreen = useCallback(() => {
ref.current?.enterFullscreen()
@ -46,12 +47,13 @@ export function VideoEmbedInnerNative({
player={player}
style={[a.flex_1, a.rounded_sm]}
contentFit="contain"
nativeControls={false}
nativeControls={isFullscreen}
accessibilityIgnoresInvertColors
onEnterFullscreen={() => {
PlatformInfo.setAudioCategory(AudioCategory.Playback)
PlatformInfo.setAudioActive(true)
player.muted = false
setIsFullscreen(true)
}}
onExitFullscreen={() => {
PlatformInfo.setAudioCategory(AudioCategory.Ambient)
@ -60,6 +62,7 @@ export function VideoEmbedInnerNative({
if (!player.playing) {
player.play()
}
setIsFullscreen(false)
}}
accessibilityLabel={
embed.alt ? _(msg`Video: ${embed.alt}`) : _(msg`Video`)