mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Merge pull request #492 from de1acr0ix/fullscreen-video-play-from-start
Always play video in fullscreen from beginning
This commit is contained in:
@ -26,7 +26,6 @@ const AttachmentVideo: React.FC<Props> = ({
|
|||||||
const videoPlayer = useRef<Video>(null)
|
const videoPlayer = useRef<Video>(null)
|
||||||
const [videoLoading, setVideoLoading] = useState(false)
|
const [videoLoading, setVideoLoading] = useState(false)
|
||||||
const [videoLoaded, setVideoLoaded] = useState(false)
|
const [videoLoaded, setVideoLoaded] = useState(false)
|
||||||
const [videoPosition, setVideoPosition] = useState<number>(0)
|
|
||||||
const [videoResizeMode, setVideoResizeMode] = useState<ResizeMode>(ResizeMode.COVER)
|
const [videoResizeMode, setVideoResizeMode] = useState<ResizeMode>(ResizeMode.COVER)
|
||||||
const playOnPress = useCallback(async () => {
|
const playOnPress = useCallback(async () => {
|
||||||
setVideoLoading(true)
|
setVideoLoading(true)
|
||||||
@ -34,19 +33,15 @@ const AttachmentVideo: React.FC<Props> = ({
|
|||||||
await videoPlayer.current?.loadAsync({ uri: video.url })
|
await videoPlayer.current?.loadAsync({ uri: video.url })
|
||||||
}
|
}
|
||||||
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.CONTAIN)
|
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.CONTAIN)
|
||||||
await videoPlayer.current?.setPositionAsync(videoPosition)
|
|
||||||
await videoPlayer.current?.presentFullscreenPlayer()
|
await videoPlayer.current?.presentFullscreenPlayer()
|
||||||
videoPlayer.current?.playAsync()
|
videoPlayer.current?.playAsync()
|
||||||
setVideoLoading(false)
|
setVideoLoading(false)
|
||||||
videoPlayer.current?.setOnPlaybackStatusUpdate(props => {
|
videoPlayer.current?.setOnPlaybackStatusUpdate(props => {
|
||||||
if (props.isLoaded) {
|
if (props.isLoaded) {
|
||||||
setVideoLoaded(true)
|
setVideoLoaded(true)
|
||||||
if (props.positionMillis) {
|
|
||||||
setVideoPosition(props.positionMillis)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [videoLoaded, videoPosition])
|
}, [videoLoaded])
|
||||||
|
|
||||||
const appState = useRef(AppState.currentState)
|
const appState = useRef(AppState.currentState)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -107,7 +102,7 @@ const AttachmentVideo: React.FC<Props> = ({
|
|||||||
if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
|
if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
|
||||||
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.COVER)
|
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.COVER)
|
||||||
if (!gifv) {
|
if (!gifv) {
|
||||||
await videoPlayer.current?.pauseAsync()
|
await videoPlayer.current?.stopAsync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user