mirror of
https://github.com/tooot-app/app
synced 2024-12-22 07:34:06 +01:00
Always play video in fullscreen from beginning
This commit is contained in:
parent
bd750da9d5
commit
0a5fea1194
@ -27,7 +27,6 @@ const AttachmentVideo: React.FC<Props> = ({
|
||||
const videoPlayer = useRef<Video>(null)
|
||||
const [videoLoading, setVideoLoading] = useState(false)
|
||||
const [videoLoaded, setVideoLoaded] = useState(false)
|
||||
const [videoPosition, setVideoPosition] = useState<number>(0)
|
||||
const [videoResizeMode, setVideoResizeMode] = useState<ResizeMode>(ResizeMode.COVER)
|
||||
const playOnPress = useCallback(async () => {
|
||||
analytics('timeline_shared_attachment_video_length', {
|
||||
@ -42,19 +41,15 @@ const AttachmentVideo: React.FC<Props> = ({
|
||||
await videoPlayer.current?.loadAsync({ uri: video.url })
|
||||
}
|
||||
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.CONTAIN)
|
||||
await videoPlayer.current?.setPositionAsync(videoPosition)
|
||||
await videoPlayer.current?.presentFullscreenPlayer()
|
||||
videoPlayer.current?.playAsync()
|
||||
setVideoLoading(false)
|
||||
videoPlayer.current?.setOnPlaybackStatusUpdate(props => {
|
||||
if (props.isLoaded) {
|
||||
setVideoLoaded(true)
|
||||
if (props.positionMillis) {
|
||||
setVideoPosition(props.positionMillis)
|
||||
}
|
||||
}
|
||||
})
|
||||
}, [videoLoaded, videoPosition])
|
||||
}, [videoLoaded])
|
||||
|
||||
const appState = useRef(AppState.currentState)
|
||||
useEffect(() => {
|
||||
@ -115,7 +110,7 @@ const AttachmentVideo: React.FC<Props> = ({
|
||||
if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
|
||||
Platform.OS === 'android' && setVideoResizeMode(ResizeMode.COVER)
|
||||
if (!gifv) {
|
||||
await videoPlayer.current?.pauseAsync()
|
||||
await videoPlayer.current?.stopAsync()
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user