2

I am following a tutorial on how to build a cameraX custom camera and i'm stuck.

In the tutorial he uses this:

        PreviewConfig previewConfig = new PreviewConfig.Builder().setTargetAspectRatioCustom(aspectRatio).build();
        Preview preview = new Preview(previewConfig)
        preview.setOnPreviewOutputUpdateListener() { 
            ...
        }

I found out that this method changed and now you don't need PreviewConfig so you can just do it like this:

        Preview preview = new Preview.Builder().setTargetAspectRatioCustom(aspectRatio).build();

But the setOnPreviewOutputUpdateListener() method does not exist anymore for Preview (Cannot resolve symbol 'setOnPreviewOutputUpdateListener'). How can i handle this?

Thank you very much.

  • have a look at this https://developer.android.com/training/camera/cameradirect and this link also for cameraX https://developer.android.com/training/camerax/preview – Prathamesh May 23 '20 at 16:47
  • Or even better, just go through the [CameraX codelab](https://codelabs.developers.google.com/codelabs/camerax-getting-started/#0). – Husayn Hakeem May 23 '20 at 18:30
  • Thank you, I've managed to make it work but now I was wondering if there is any way to record video as well with CameraX. Every tutorial i've found is just for images, while for video recording i've only found tutorials for camera and camera2 which are several years old. Thank you! – Adrian Cosmin May 23 '20 at 20:42
  • CameraX still doesn't officially support video capture. It has a hidden API for a VideoCapture use case which is still in a preliminary state. Check out this other [SO question](https://stackoverflow.com/questions/56054647/can-i-record-video-with-camerax-android-jetpack). – Husayn Hakeem May 23 '20 at 21:25

0 Answers0