allow gifs on native, treat as videos
This commit is contained in:
@@ -20,6 +20,13 @@ export async function compressVideo(
|
|||||||
file.mimeType as SupportedMimeTypes,
|
file.mimeType as SupportedMimeTypes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (file.mimeType === 'image/gif') {
|
||||||
|
// let's hope they're small enough that they don't need compression!
|
||||||
|
// this compression library doesn't support gifs
|
||||||
|
// worst case - server rejects them. I think that's fine -sfn
|
||||||
|
return {uri: file.uri, size: file.fileSize ?? -1, mimeType: 'image/gif'}
|
||||||
|
}
|
||||||
|
|
||||||
const minimumFileSizeForCompress = isAcceptableFormat
|
const minimumFileSizeForCompress = isAcceptableFormat
|
||||||
? MIN_SIZE_FOR_COMPRESSION
|
? MIN_SIZE_FOR_COMPRESSION
|
||||||
: 0
|
: 0
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {useCallback} from 'react'
|
import {useCallback} from 'react'
|
||||||
|
import {Keyboard} from 'react-native'
|
||||||
import {
|
import {
|
||||||
type ImagePickerAsset,
|
type ImagePickerAsset,
|
||||||
launchImageLibraryAsync,
|
launchImageLibraryAsync,
|
||||||
@@ -176,7 +177,7 @@ function classifyImagePickerAsset(asset: ImagePickerAsset):
|
|||||||
* Distill this down into a type "class".
|
* Distill this down into a type "class".
|
||||||
*/
|
*/
|
||||||
let type: AssetType | undefined
|
let type: AssetType | undefined
|
||||||
if (isWeb && mimeType === 'image/gif') {
|
if (mimeType === 'image/gif') {
|
||||||
type = 'gif'
|
type = 'gif'
|
||||||
} else if (mimeType?.startsWith('video/')) {
|
} else if (mimeType?.startsWith('video/')) {
|
||||||
type = 'video'
|
type = 'video'
|
||||||
@@ -436,6 +437,10 @@ export function SelectMediaButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Keyboard.isVisible()) {
|
||||||
|
Keyboard.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
const {assets, canceled} = await sheetWrapper(
|
const {assets, canceled} = await sheetWrapper(
|
||||||
launchImageLibraryAsync({
|
launchImageLibraryAsync({
|
||||||
exif: false,
|
exif: false,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {ImagePickerAsset} from 'expo-image-picker'
|
import {Image} from 'expo-image'
|
||||||
|
import {type ImagePickerAsset} from 'expo-image-picker'
|
||||||
import {BlueskyVideoView} from '@haileyok/bluesky-video'
|
import {BlueskyVideoView} from '@haileyok/bluesky-video'
|
||||||
|
|
||||||
import {CompressedVideo} from '#/lib/media/video/types'
|
import {type CompressedVideo} from '#/lib/media/video/types'
|
||||||
import {clamp} from '#/lib/numbers'
|
import {clamp} from '#/lib/numbers'
|
||||||
import {useAutoplayDisabled} from '#/state/preferences'
|
import {useAutoplayDisabled} from '#/state/preferences'
|
||||||
import {ExternalEmbedRemoveBtn} from '#/view/com/composer/ExternalEmbedRemoveBtn'
|
import {ExternalEmbedRemoveBtn} from '#/view/com/composer/ExternalEmbedRemoveBtn'
|
||||||
@@ -48,13 +49,25 @@ export function VideoPreview({
|
|||||||
<VideoTranscodeBackdrop uri={asset.uri} />
|
<VideoTranscodeBackdrop uri={asset.uri} />
|
||||||
</View>
|
</View>
|
||||||
{isActivePost && (
|
{isActivePost && (
|
||||||
<BlueskyVideoView
|
<>
|
||||||
url={video.uri}
|
{video.mimeType === 'image/gif' ? (
|
||||||
autoplay={!autoplayDisabled}
|
<Image
|
||||||
beginMuted={true}
|
style={[a.flex_1]}
|
||||||
forceTakeover={true}
|
autoplay={!autoplayDisabled}
|
||||||
ref={playerRef}
|
source={{uri: video.uri}}
|
||||||
/>
|
accessibilityIgnoresInvertColors
|
||||||
|
cachePolicy="none"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<BlueskyVideoView
|
||||||
|
url={video.uri}
|
||||||
|
autoplay={!autoplayDisabled}
|
||||||
|
beginMuted={true}
|
||||||
|
forceTakeover={true}
|
||||||
|
ref={playerRef}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<ExternalEmbedRemoveBtn onRemove={clear} />
|
<ExternalEmbedRemoveBtn onRemove={clear} />
|
||||||
{autoplayDisabled && (
|
{autoplayDisabled && (
|
||||||
|
|||||||
Reference in New Issue
Block a user