mirror of
https://github.com/tooot-app/app
synced 2024-12-22 07:34:06 +01:00
Merge pull request #492 from de1acr0ix/fullscreen-video-play-from-start
Always play video in fullscreen from beginning
This commit is contained in:
commit
35bf588b75
@ -26,7 +26,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 () => {
|
||||
setVideoLoading(true)
|
||||
@ -34,19 +33,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(() => {
|
||||
@ -107,7 +102,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