Skip to content

Commit

Permalink
fail video if cannot load preview (#5138)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored Sep 4, 2024
1 parent 3eef62d commit 515f87e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/view/com/composer/videos/VideoPreview.web.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React, {useEffect, useRef} from 'react'
import {View} from 'react-native'
import {ImagePickerAsset} from 'expo-image-picker'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {CompressedVideo} from '#/lib/media/video/types'
import {clamp} from '#/lib/numbers'
import * as Toast from '#/view/com/util/Toast'
import {ExternalEmbedRemoveBtn} from 'view/com/composer/ExternalEmbedRemoveBtn'
import {atoms as a} from '#/alf'

Expand All @@ -19,6 +22,7 @@ export function VideoPreview({
clear: () => void
}) {
const ref = useRef<HTMLVideoElement>(null)
const {_} = useLingui()

useEffect(() => {
if (!ref.current) return
Expand All @@ -32,11 +36,19 @@ export function VideoPreview({
},
{signal},
)
ref.current.addEventListener(
'error',
() => {
Toast.show(_(msg`Could not process your video`))
clear()
},
{signal},
)

return () => {
abortController.abort()
}
}, [setDimensions])
}, [setDimensions, _, clear])

let aspectRatio = asset.width / asset.height

Expand Down

0 comments on commit 515f87e

Please sign in to comment.