Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Video] Cap duration (#5270)

authored by

Samuel Newman and committed by
GitHub
24b07c6c a19c91d9

+20 -2
+9 -2
src/view/com/composer/videos/SelectVideoBtn.tsx
··· 18 18 import {VideoClip_Stroke2_Corner0_Rounded as VideoClipIcon} from '#/components/icons/VideoClip' 19 19 import * as Prompt from '#/components/Prompt' 20 20 21 - const VIDEO_MAX_DURATION = 60 21 + const VIDEO_MAX_DURATION = 60 * 1000 // 60s in milliseconds 22 22 23 23 type Props = { 24 24 onSelectVideo: (video: ImagePickerAsset) => void ··· 45 45 const response = await launchImageLibraryAsync({ 46 46 exif: false, 47 47 mediaTypes: MediaTypeOptions.Videos, 48 - videoMaxDuration: VIDEO_MAX_DURATION, 49 48 quality: 1, 50 49 legacy: true, 51 50 preferredAssetRepresentationMode: 52 51 UIImagePickerPreferredAssetRepresentationMode.Current, 53 52 }) 54 53 if (response.assets && response.assets.length > 0) { 54 + if (isNative) { 55 + if (typeof response.assets[0].duration !== 'number') 56 + throw Error('Asset is not a video') 57 + if (response.assets[0].duration > VIDEO_MAX_DURATION) { 58 + setError(_(msg`Videos must be less than 60 seconds long`)) 59 + return 60 + } 61 + } 55 62 try { 56 63 onSelectVideo(response.assets[0]) 57 64 } catch (err) {
+11
src/view/com/composer/videos/VideoPreview.web.tsx
··· 12 12 import {atoms as a} from '#/alf' 13 13 import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' 14 14 15 + const MAX_DURATION = 60 16 + 15 17 export function VideoPreview({ 16 18 asset, 17 19 video, ··· 36 38 'loadedmetadata', 37 39 function () { 38 40 setDimensions(this.videoWidth, this.videoHeight) 41 + if (!isNaN(this.duration)) { 42 + if (this.duration > MAX_DURATION) { 43 + Toast.show( 44 + _(msg`Videos must be less than 60 seconds long`), 45 + 'xmark', 46 + ) 47 + clear() 48 + } 49 + } 39 50 }, 40 51 {signal}, 41 52 )