Skip to content

Commit 515f87e

Browse files
authored
fail video if cannot load preview (#5138)
1 parent 3eef62d commit 515f87e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/view/com/composer/videos/VideoPreview.web.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import React, {useEffect, useRef} from 'react'
22
import {View} from 'react-native'
33
import {ImagePickerAsset} from 'expo-image-picker'
4+
import {msg} from '@lingui/macro'
5+
import {useLingui} from '@lingui/react'
46

57
import {CompressedVideo} from '#/lib/media/video/types'
68
import {clamp} from '#/lib/numbers'
9+
import * as Toast from '#/view/com/util/Toast'
710
import {ExternalEmbedRemoveBtn} from 'view/com/composer/ExternalEmbedRemoveBtn'
811
import {atoms as a} from '#/alf'
912

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

2327
useEffect(() => {
2428
if (!ref.current) return
@@ -32,11 +36,19 @@ export function VideoPreview({
3236
},
3337
{signal},
3438
)
39+
ref.current.addEventListener(
40+
'error',
41+
() => {
42+
Toast.show(_(msg`Could not process your video`))
43+
clear()
44+
},
45+
{signal},
46+
)
3547

3648
return () => {
3749
abortController.abort()
3850
}
39-
}, [setDimensions])
51+
}, [setDimensions, _, clear])
4052

4153
let aspectRatio = asset.width / asset.height
4254

0 commit comments

Comments
 (0)