parent
95aee146b6
commit
6c6a76b193
|
@ -2,6 +2,7 @@ import {getVideoMetaData, Video} from 'react-native-compressor'
|
||||||
import {ImagePickerAsset} from 'expo-image-picker'
|
import {ImagePickerAsset} from 'expo-image-picker'
|
||||||
|
|
||||||
import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants'
|
import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants'
|
||||||
|
import {extToMime} from '#/state/queries/video/util'
|
||||||
import {CompressedVideo} from './types'
|
import {CompressedVideo} from './types'
|
||||||
|
|
||||||
const MIN_SIZE_FOR_COMPRESSION = 1024 * 1024 * 25 // 25mb
|
const MIN_SIZE_FOR_COMPRESSION = 1024 * 1024 * 25 // 25mb
|
||||||
|
@ -43,5 +44,5 @@ export async function compressVideo(
|
||||||
|
|
||||||
const info = await getVideoMetaData(compressed)
|
const info = await getVideoMetaData(compressed)
|
||||||
|
|
||||||
return {uri: compressed, size: info.size, mimeType: `video/mp4`}
|
return {uri: compressed, size: info.size, mimeType: extToMime(info.extension)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,3 +39,18 @@ export function mimeToExt(mimeType: SupportedMimeTypes | (string & {})) {
|
||||||
throw new Error(`Unsupported mime type: ${mimeType}`)
|
throw new Error(`Unsupported mime type: ${mimeType}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function extToMime(ext: string) {
|
||||||
|
switch (ext) {
|
||||||
|
case 'mp4':
|
||||||
|
return 'video/mp4'
|
||||||
|
case 'webm':
|
||||||
|
return 'video/webm'
|
||||||
|
case 'mpeg':
|
||||||
|
return 'video/mpeg'
|
||||||
|
case 'mov':
|
||||||
|
return 'video/quicktime'
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported file extension: ${ext}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1154,10 +1154,12 @@ function VideoUploadToolbar({state}: {state: VideoUploadState}) {
|
||||||
const progress = state.jobStatus?.progress
|
const progress = state.jobStatus?.progress
|
||||||
? state.jobStatus.progress / 100
|
? state.jobStatus.progress / 100
|
||||||
: state.progress
|
: state.progress
|
||||||
let wheelProgress = progress === 0 || progress === 1 ? 0.33 : progress
|
const shouldRotate =
|
||||||
|
state.status === 'processing' && (progress === 0 || progress === 1)
|
||||||
|
let wheelProgress = shouldRotate ? 0.33 : progress
|
||||||
|
|
||||||
const rotate = useDerivedValue(() => {
|
const rotate = useDerivedValue(() => {
|
||||||
if (progress === 0 || progress >= 0.99) {
|
if (shouldRotate) {
|
||||||
return withRepeat(
|
return withRepeat(
|
||||||
withTiming(360, {
|
withTiming(360, {
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
|
|
Loading…
Reference in New Issue