[Video] Cap duration (#5270)

This commit is contained in:
Samuel Newman
2024-09-11 18:33:57 +01:00
committed by GitHub
parent a19c91d90e
commit 24b07c6cf4
2 changed files with 20 additions and 2 deletions
@@ -12,6 +12,8 @@ import {ExternalEmbedRemoveBtn} from 'view/com/composer/ExternalEmbedRemoveBtn'
import {atoms as a} from '#/alf'
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'
const MAX_DURATION = 60
export function VideoPreview({
asset,
video,
@@ -36,6 +38,15 @@ export function VideoPreview({
'loadedmetadata',
function () {
setDimensions(this.videoWidth, this.videoHeight)
if (!isNaN(this.duration)) {
if (this.duration > MAX_DURATION) {
Toast.show(
_(msg`Videos must be less than 60 seconds long`),
'xmark',
)
clear()
}
}
},
{signal},
)