Expo-Camera for local simulator development is not supported, how to work around this?

273 Views Asked by At

expo-camera is not supported by any of the simulators. Therefore, when using this component in development & on the simulator, it results in an error and data is not stored as it would on the actual device.

Possible Unhandled Promise Rejection. Error: Video recording is not supported on a simulator

This is causing an issue in terms of verifying functionality and the "happy path".
I added an interim check for a video field and then return the basic camera, so at least our flow works, but I don't think it's a long terms solution:

 if (
      process.env.NODE_ENV === 'development' &&
      field.kind === ComponentTypes.VIDEO
    ) {
       return <CameraImage />
    }

How do you work around this intended behavior, in terms of getting data to store? All I can think of doing for this is adding a catch and faking the data:

 cameraRef?.current
        .recordAsync(options)
        .then(vid => {
          console.log({ vid });

          setRecordedVideo(vid);
        })
        .catch(() => {
          if (process.env.NODE_ENV === 'development') {
            setRecordedVideo({
              uri: someFakeUri,
            });
          }
        })
        .finally(() => setIsRecording(false));
0

There are 0 best solutions below