diff options
Diffstat (limited to 'src/view/com/composer/videos/VideoPreview.tsx')
-rw-r--r-- | src/view/com/composer/videos/VideoPreview.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/view/com/composer/videos/VideoPreview.tsx b/src/view/com/composer/videos/VideoPreview.tsx index 994076273..3a823b7ed 100644 --- a/src/view/com/composer/videos/VideoPreview.tsx +++ b/src/view/com/composer/videos/VideoPreview.tsx @@ -5,6 +5,7 @@ import {ImagePickerAsset} from 'expo-image-picker' import {useVideoPlayer, VideoView} from 'expo-video' import {CompressedVideo} from '#/lib/media/video/types' +import {clamp} from '#/lib/numbers' import {ExternalEmbedRemoveBtn} from 'view/com/composer/ExternalEmbedRemoveBtn' import {atoms as a, useTheme} from '#/alf' @@ -25,23 +26,31 @@ export function VideoPreview({ player.play() }) - const aspectRatio = asset.width / asset.height + let aspectRatio = asset.width / asset.height + + if (isNaN(aspectRatio)) { + aspectRatio = 16 / 9 + } + + aspectRatio = clamp(aspectRatio, 1 / 1, 3 / 1) return ( <View style={[ a.w_full, a.rounded_sm, - {aspectRatio: isNaN(aspectRatio) ? 16 / 9 : aspectRatio}, + {aspectRatio}, a.overflow_hidden, a.border, t.atoms.border_contrast_low, + {backgroundColor: t.palette.black}, ]}> <VideoView player={player} style={a.flex_1} allowsPictureInPicture={false} nativeControls={false} + contentFit="contain" /> <ExternalEmbedRemoveBtn onRemove={clear} /> </View> |