diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/api/index.ts | 20 | ||||
-rw-r--r-- | src/view/com/composer/videos/pickVideo.ts | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 7621fbb4c..20f0745d6 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -333,15 +333,27 @@ async function resolveMedia( return {lang: caption.lang, file: data.blob} }), ) + + // lexicon numbers must be floats + const width = Math.round(videoDraft.asset.width) + const height = Math.round(videoDraft.asset.height) + + // aspect ratio values must be >0 - better to leave as unset otherwise + // posting will fail if aspect ratio is set to 0 + const aspectRatio = width > 0 && height > 0 ? {width, height} : undefined + + if (!aspectRatio) { + logger.error( + `Invalid aspect ratio - got { width: ${videoDraft.asset.width}, height: ${videoDraft.asset.height} }`, + ) + } + return { $type: 'app.bsky.embed.video', video: videoDraft.pendingPublish.blobRef, alt: videoDraft.altText || undefined, captions: captions.length === 0 ? undefined : captions, - aspectRatio: { - width: videoDraft.asset.width, - height: videoDraft.asset.height, - }, + aspectRatio, } } if (embedDraft.media?.type === 'gif') { diff --git a/src/view/com/composer/videos/pickVideo.ts b/src/view/com/composer/videos/pickVideo.ts index 13bb96805..a55b69c1d 100644 --- a/src/view/com/composer/videos/pickVideo.ts +++ b/src/view/com/composer/videos/pickVideo.ts @@ -1,5 +1,5 @@ import { - ImagePickerAsset, + type ImagePickerAsset, launchImageLibraryAsync, UIImagePickerPreferredAssetRepresentationMode, } from 'expo-image-picker' |