I have been stuck in this issue for days.
I followed this Android's official camera-sample in Kotlin: android's camera-sample
I raised an issue on github issue on 11 Feb 2020 but haven't received any feedback.
My problem is:
I used the sample as it is and only changed val cameraId = manager.cameraIdList[0]
to val cameraId = manager.cameraIdList[1]
for front camera.
NOTE: It does not happen in rear camera.
The front camera does not work and shows black bar on devices tested:
- Emulator: Pixel C API 29
- Device: Galaxy Tab S2
- Mode: Portrait
I wanted a full screen view, so when I don't set the aspect ratio of AutoTextureView
in the commented line below, the video takes full screen but is now stretched.
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
//I only have portrait mode
} else {
//textureView.setAspectRatio(previewSize.height, previewSize.width)
}
Is there a way to set full screen mode without any stretching or in a correct aspect ratio?
I have been through following solutions in slack and none worked for me:
Camera 2 : Unable to record video in full screen?
Camera2 API Make Preview Fill Entire View
Android Camera2 API stretching the preview