ThibaultBee / StreamPack

SRT/RTMP/RTMPS live streaming libraries for Android
https://thibaultbee.github.io/StreamPack/index.html
Apache License 2.0
193 stars 68 forks source link

CameraX use Preview but this lib use AutoFitSurfaceView.How to switch front back camera? #33

Closed Squall-Huang closed 2 years ago

Squall-Huang commented 2 years ago
preview.setSurfaceProvider(
                previewView.getSurfaceProvider())

Because AutoFitSurfaceView can't get SurfaceProvider, how to switch from back camera to front camera?

ThibaultBee commented 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:

Squall-Huang commented 2 years ago

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.