I am trying to implement Custom Camera to record a video. I have followed This sample and it is working fine.
Now, i want to add "Switch Camera" functionality over a Button click. It should be able to Switch between Front/Back Camera even while the video is getting recorded.
Hence please help me to know if it is even possible??
1. If yes then How??
2. If no then Please suggest some workaround??
Some sample codes or links would be very helpful...
Note : I have been googling about it and found some StackOverFlow answers like
Android Camera2 API switch back - front cameras
Android: Switch camera when button clicked
But none of these are giving a facility to switch the camera when the video is being recorded.
Please Help.
The code is same as This sample. And it's the Camera2 API.
Get Dual Camera app: Front and Back from Android PlayStore Once downloaded follow these steps: Tap on the camera icon at the centre. Choose the layout in which you want to shoot the video, and select video quality. The final step is just tapping on the record button.
Tap the Tools option at the bottom of the screen, then select Rotate from the menu that appears. At the bottom of the display you'll see an icon the has two arrows pointing at each other, with a dotted vertical line between them. Tap this and you should see your image flip back to a normal orientation.
As far as i concerned, that camera is device and @Selvin explained front and back cameras are different devices.Now let me start from first,
Some of the device has own functionality that you can switch the camera during video is recording.like Nexus 9. For more detail please refer this question.
Another way you can do by using MediaRecorder. You can implement like this question's answer. how to switch between front and back camera when using MediaRecorder android?
I have no more idea about that but if you want to do then do like this:-
1. When your record video using back camera and switch to front camera then temporary save that video in local and star with front camera.
2. now stop the video recording then marge that both file and save as single file..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With