diff options
Diffstat (limited to 'src/view/com/composer/videos')
-rw-r--r-- | src/view/com/composer/videos/VideoPreview.tsx | 1 | ||||
-rw-r--r-- | src/view/com/composer/videos/VideoTranscodeProgress.tsx | 8 | ||||
-rw-r--r-- | src/view/com/composer/videos/state.ts | 51 |
3 files changed, 5 insertions, 55 deletions
diff --git a/src/view/com/composer/videos/VideoPreview.tsx b/src/view/com/composer/videos/VideoPreview.tsx index b04cdf1c8..8e2a22852 100644 --- a/src/view/com/composer/videos/VideoPreview.tsx +++ b/src/view/com/composer/videos/VideoPreview.tsx @@ -17,6 +17,7 @@ export function VideoPreview({ const player = useVideoPlayer(video.uri, player => { player.loop = true player.play() + player.volume = 0 }) return ( diff --git a/src/view/com/composer/videos/VideoTranscodeProgress.tsx b/src/view/com/composer/videos/VideoTranscodeProgress.tsx index 79407cd3e..db58448a3 100644 --- a/src/view/com/composer/videos/VideoTranscodeProgress.tsx +++ b/src/view/com/composer/videos/VideoTranscodeProgress.tsx @@ -9,15 +9,15 @@ import {Text} from '#/components/Typography' import {VideoTranscodeBackdrop} from './VideoTranscodeBackdrop' export function VideoTranscodeProgress({ - input, + asset, progress, }: { - input: ImagePickerAsset + asset: ImagePickerAsset progress: number }) { const t = useTheme() - const aspectRatio = input.width / input.height + const aspectRatio = asset.width / asset.height return ( <View @@ -29,7 +29,7 @@ export function VideoTranscodeProgress({ a.overflow_hidden, {aspectRatio: isNaN(aspectRatio) ? 16 / 9 : aspectRatio}, ]}> - <VideoTranscodeBackdrop uri={input.uri} /> + <VideoTranscodeBackdrop uri={asset.uri} /> <View style={[ a.flex_1, diff --git a/src/view/com/composer/videos/state.ts b/src/view/com/composer/videos/state.ts deleted file mode 100644 index 3670f3d1f..000000000 --- a/src/view/com/composer/videos/state.ts +++ /dev/null @@ -1,51 +0,0 @@ -import {useState} from 'react' -import {ImagePickerAsset} from 'expo-image-picker' -import {msg} from '@lingui/macro' -import {useLingui} from '@lingui/react' -import {useMutation} from '@tanstack/react-query' - -import {compressVideo} from '#/lib/media/video/compress' -import {logger} from '#/logger' -import {VideoTooLargeError} from 'lib/media/video/errors' -import * as Toast from 'view/com/util/Toast' - -export function useVideoState({setError}: {setError: (error: string) => void}) { - const {_} = useLingui() - const [progress, setProgress] = useState(0) - - const {mutate, data, isPending, isError, reset, variables} = useMutation({ - mutationFn: async (asset: ImagePickerAsset) => { - const compressed = await compressVideo(asset.uri, { - onProgress: num => setProgress(trunc2dp(num)), - }) - - return compressed - }, - onError: (e: any) => { - // Don't log these errors in sentry, just let the user know - if (e instanceof VideoTooLargeError) { - Toast.show(_(msg`Videos cannot be larger than 100MB`), 'xmark') - return - } - logger.error('Failed to compress video', {safeError: e}) - setError(_(msg`Could not compress video`)) - }, - onMutate: () => { - setProgress(0) - }, - }) - - return { - video: data, - onSelectVideo: mutate, - videoPending: isPending, - videoProcessingData: variables, - videoError: isError, - clearVideo: reset, - videoProcessingProgress: progress, - } -} - -function trunc2dp(num: number) { - return Math.trunc(num * 100) / 100 -} |