From e2e5e80aaf89793c38f157706ad1516c0cffc27f Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sun, 4 Dec 2022 18:42:01 +0100 Subject: [PATCH] Remove previous fix attempts #499 --- .../Timeline/Shared/Attachment/AltText.tsx | 4 +- .../Timeline/Shared/Attachment/Video.tsx | 71 ++++++------------- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/components/Timeline/Shared/Attachment/AltText.tsx b/src/components/Timeline/Shared/Attachment/AltText.tsx index 59775ac5..ce1bf2a6 100644 --- a/src/components/Timeline/Shared/Attachment/AltText.tsx +++ b/src/components/Timeline/Shared/Attachment/AltText.tsx @@ -28,9 +28,7 @@ const AttachmentAltText: React.FC = ({ sensitiveShown, text }) => { type='text' content='ALT' fontBold - onPress={() => { - navigation.navigate('Screen-Actions', { type: 'alt_text', text }) - }} + onPress={() => navigation.navigate('Screen-Actions', { type: 'alt_text', text })} /> ) : null } diff --git a/src/components/Timeline/Shared/Attachment/Video.tsx b/src/components/Timeline/Shared/Attachment/Video.tsx index c868210f..518a5b78 100644 --- a/src/components/Timeline/Shared/Attachment/Video.tsx +++ b/src/components/Timeline/Shared/Attachment/Video.tsx @@ -1,8 +1,8 @@ import Button from '@components/Button' import { StyleConstants } from '@utils/styles/constants' import { ResizeMode, Video, VideoFullscreenUpdate } from 'expo-av' -import React, { useCallback, useEffect, useRef, useState } from 'react' -import { AppState, AppStateStatus, Pressable, View } from 'react-native' +import React, { useRef, useState } from 'react' +import { Pressable, View } from 'react-native' import { Blurhash } from 'react-native-blurhash' import attachmentAspectRatio from './aspectRatio' import AttachmentAltText from './AltText' @@ -27,46 +27,19 @@ const AttachmentVideo: React.FC = ({ const [videoLoading, setVideoLoading] = useState(false) const [videoLoaded, setVideoLoaded] = useState(false) const [videoResizeMode, setVideoResizeMode] = useState(ResizeMode.COVER) - const playOnPress = useCallback(async () => { + const playOnPress = async () => { setVideoLoading(true) if (!videoLoaded) { await videoPlayer.current?.loadAsync({ uri: video.url }) } + setVideoLoading(false) + Platform.OS === 'android' && setVideoResizeMode(ResizeMode.CONTAIN) await videoPlayer.current?.presentFullscreenPlayer() + videoPlayer.current?.playAsync() - setVideoLoading(false) - videoPlayer.current?.setOnPlaybackStatusUpdate(props => { - if (props.isLoaded) { - setVideoLoaded(true) - } - }) - }, [videoLoaded]) - - const appState = useRef(AppState.currentState) - useEffect(() => { - const appState = AppState.addEventListener('change', _handleAppStateChange) - - return () => appState.remove() - }, []) - const _handleAppStateChange = async (nextAppState: AppStateStatus) => { - if (appState.current.match(/active/) && nextAppState.match(/inactive/)) { - // await videoPlayer.current?.stopAsync() - } else if (gifv && appState.current.match(/background/) && nextAppState.match(/active/)) { - await videoPlayer.current?.setIsMutedAsync(true) - await videoPlayer.current?.playAsync() - } - - appState.current = nextAppState } - const playerStatus = useRef(null) - useEffect(() => { - videoPlayer.current?.setOnPlaybackStatusUpdate(playbackStatus => { - playerStatus.current = playbackStatus - }) - }, []) - return ( = ({