Skip to content

I need to implement limit of 30 seconds in video recording #2235

Description

@TikshaK

I have implemented picker for camera recordings and video picking. I want the feature in which the camera records no more than 30 seconds. If user wishes then he/she can stop recording before 30 seconds but if they don't then after reaching 30 seconds of recording the camera stops itself and media is picked. I tried to use durationLimit: 30, prop but this isn't helping.

captureFromCamera: async (): Promise<MediaResult | null> => {
try {
const cameraPermission = await PermissionUtils.checkAndRequestPermission("camera");
if (!cameraPermission) return null;

  return new Promise((resolve) => {
    Alert.alert(
      "Capture Media",
      "Choose what to capture",
      [
        {
          text: "Photo",
          onPress: async () => {
            const img = await ImageCropPicker.openCamera({
              cropping: true,
              compressImageQuality: 0.8,
              mediaType: "photo",
            });
            resolve(img);
          },
        },
        {
          text: "Video",
          onPress: async () => {
            const video = await ImageCropPicker.openCamera({
              mediaType: "video",
              compressVideoPreset: "MediumQuality",
              durationLimit: 30,
              
            });
            resolve(video);
          },
        },
        { text: "Cancel", style: "cancel", onPress: () => resolve(null) },
      ]
    );
  });
} catch (err: any) {
  if (err?.code !== "E_PICKER_CANCELLED") Alert.alert("Error", err.message);
  return null;
}

},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions