[Video] Minor player tweaks (#5044)

This commit is contained in:
Samuel Newman 2024-08-30 20:48:23 +01:00 committed by GitHub
parent 8647c8e9f5
commit ab260c3599
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 35 additions and 15 deletions

View file

@ -3,6 +3,7 @@ import {View} from 'react-native'
import {ImagePickerAsset} from 'expo-image-picker'
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'
@ -38,15 +39,20 @@ export function VideoPreview({
}
}, [setDimensions])
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,
{backgroundColor: t.palette.black},
]}>