import {View} from 'react-native' import {type ImagePickerAsset} from 'expo-image-picker' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {type CompressedVideo} from '#/lib/media/video/types' import {clamp} from '#/lib/numbers' import {useAutoplayDisabled} from '#/state/preferences' import {ExternalEmbedRemoveBtn} from '#/view/com/composer/ExternalEmbedRemoveBtn' import * as Toast from '#/view/com/util/Toast' import {atoms as a} from '#/alf' import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' export function VideoPreview({ asset, video, clear, }: { asset: ImagePickerAsset video: CompressedVideo clear: () => void }) { const {_} = useLingui() // TODO: figure out how to pause a GIF for reduced motion // it's not possible using an img tag -sfn const autoplayDisabled = useAutoplayDisabled() let aspectRatio = asset.width / asset.height if (isNaN(aspectRatio)) { aspectRatio = 16 / 9 } aspectRatio = clamp(aspectRatio, 1 / 1, 3 / 1) return ( {video.mimeType === 'image/gif' ? ( GIF ) : ( <> ) }