Expo Camera: change zoom while recording

Please provide the following:

  1. SDK Version: 40
  2. Platforms(Android/iOS/web/all): iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Hello,

I was wondering if it was possible to change the zoom prop of expo-camera while recordAsync() is active without stopping the video recording. Currently, when I try to change zoom through the use of react-native-gesture-handler, the video immediately stops. I’m implementing the Camera component as follows:

<Camera
style={styles.camera}
type={type}
flashMode={flashMode}
ref={ref => setCameraRef(ref)}
autofocus=“on”
zoom={zoom}

The “zoom” variable is part of the component state (initialized through useState) and is modified in my handling of “PinchGestureHandler”. The zooming works fine when I am not recording video.

According to the documentation for recordAsync(): “Flipping camera during a recording results in stopping it.” Is the same true for changes to the zoom prop?

Thanks in advance and happy to post more of my code if helpful.

Hey @georgez98, could you please share a Snack or public github repo of your implementation. Being able to run it locally will help a lot.

Cheers,
Adam

Hi Adam,

Thanks so much for the reply! I’ve created a snack at the following link: Expo Camera recordAsync Zoom Test - Snack

Let me know if you have any questions about it/if there are any bugs. You can start recording video by holding down the capture button. Currently, the behavior for me is that when I start recording and then attempt to change zoom, the video recording immediately stops.

Thanks!
George

Hey @adamjnav,

Just wondering if you’d had a chance to look into this at all?

Thanks!
George

Just bumping this again - would be great to get confirmation as to whether this is possible or not. It seems that this feature exists in some packages (e.g. Getting Started | VisionCamera), but these require either ejecting from Expo or using an EAS build. We’re trying to decide whether to eject or continue using the basic managed workflow.

Thanks!

Update: it ended up being an error with the gestures. Since we were using onLongPress (for TouchableOpacity) to trigger the video recording, it seems that doing the zoom gesture caused the onPressOut to activate and end the recording. Definitely a bug we should have caught. You can see the zoom working in the following Snack: Camera Working Zoom - Snack where we’re using onPress rather than onLongPress to start the video recording.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.