React-Native-Image-Picker:如何限制用户上传超过给定长度的视频?

React-Native-Image-Picker: How do I restrict user to upload video more than given length?

我可以做些什么来限制用户上传时长超过 300 秒的视频吗?较大的视频应修剪为 300 秒,或者应禁用超过 300 秒的视频。我使用不适用于 android 的 durationLimit 道具。我使用了这个库的以下版本:

"react-native-image-picker": "^2.3.4"

然后

"react-native-image-picker": "^3.5.0",

然后

"react-native-image-picker": "^4.0.2",

都不适合我

import ImagePicker from "react-native-image-picker";
const uploadVideo = async () => {
    activateKeepAwake();
    let options = {
      title: "Select video",
      takePhotoButtonTitle: null,
      mediaType: "video",
      path: "video",
      quality: 1,
      videoQuality: "normal",
      durationLimit: 300,
      allowsEditing: true,
    };
    ImagePicker.showImagePicker(options, async (response) => {
      if (response.didCancel) {
        console.log("User cancelled image picker");
      } else if (response.error) {
        console.log("ImagePicker Error: ", response.error);
      } else if (response.customButton) {
        console.log("User tapped custom button: ", response.customButton);
      } else {
        if (response && response.uri) {
          let selectedUri;
          let videoFilePath;
          let selectedFileUri = response.uri;
          setVideoLoader(true);
          setModalAddVisible(false);
          if (
            Platform.OS === "ios" &&
            (selectedFileUri.includes(".mov") ||
              selectedFileUri.includes(".MOV"))
          ) {
            videoFilePath = await handleConvertToMP4(selectedFileUri);            
            selectedUri = "file://" + videoFilePath.path;
          } else {
            selectedUri =
              Platform.os === "ios"
                ? selectedFileUri
                : "file://" + response.path;
          }
          setVideoSource(null);
          setVideoSource(selectedUri);
          await createThumbnailForVideos(selectedUri, 1);
          var filename = selectedUri.substring(
            selectedUri.lastIndexOf("/") + 1,
            selectedUri.length
          );

          const file = {
            uri: selectedUri,
            name: selectedGroup.id + "-dev-" + filename,
          };
          uploadVideoOnS3(file, "video");
        }
      }
    });
  };

这是我的 android 权限:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

根据官方文档,durationLimit 属性适用于已录制的视频,但不适用于实时录制视频。参考:https://github.com/react-native-image-picker/react-native-image-picker/issues/1738