Closed Squall-Huang closed 2 years ago
Hi,
As a preview view, user shall provide aSurface
(in the startPreview
) and not an AutoFitSurfaceView. If you can get a Surface
from CameraX PreviewView then you can use this Surface
otherwise you will have to use another type of Surface
than PreviewView
. Is there a reason why you want to keep using AndroidX PreviewView
?
To switch from back to front camera, you can do:
startPreview
set the startup camera with cameraId = "0"
streamer.camera = "0"
"0" is the camera id, you can get the full list of camera id with Context.getCameraList()
or list of back camera with Context.getBackCameraList()
or list of front camera with Context.getFrontCameraList()
.Hi Thibault:
Thank you so much to reply my question and solve my problem.
After I use startPreview(surface, "1")
, camera change to front.
streamer.camera = "0"
can swich to back camera.
Because AutoFitSurfaceView can't get SurfaceProvider, how to switch from back camera to front camera?