WebCam switching from Front To Back


does anyone have any experience with the webcam on a Samsung tab. I have the following behavior.
After starting the webcam, the FaceCam is automatically activated and also displayed.



You can switch the webcam to backcam, but the image is not always displayed. If you switch back and forth a few times, the image will be displayed.

Is there anything else to consider (timing, param ...?) or is there a way to check via code whether the switching correctly worked?

The switching to FrontCam always works correctly.

I'm grateful for any help



Which browser are you using on your ttablet? Normally there should not be any problems as long as you stop the camera first and select a device from the list before starting the camera again. Can you provide a minimal sample project that reproduces this?

I added the web project in the attachment.
Is not very big but the screen switch from front to rear
does not always display an image. Only after switching several times.
(in this version it happened better but still too often!)

System Environment: Samsung Galaxy Tab Active3
chrome browsers

Do you have an explanation or a solution?
Thank you for your effort! (105.9 KB)



It looks like there seems to be a confusion about TWebCamera.CameraType in your project.

  • ctFront: This is used to get the default front camera. Some devices might be equipped with multiple front cameras, the browser picks one by default, we have no influence over this.
  • ctRear: This is used to get the default rear facing camera. Just as with the front facing camera, the browser picks one by default and we cannot influence this. This can be a problem if you have multiple back facing cameras that are of different types (wide-lens, macro, etc...).

None of the types above should be used in combination with SetSelectedCameraDevice. The fact that it works in your project could be just coincidence. There's a 3rd type:

  • ctSelected: This is what you actually need to set the camera type to if you are planning on using SetSelectedCameraDevice. With this you are telling the component to stop trying to get a default camera but use the one you select.

Try changing the CameraType in your project to ctSelected and see if it improves the behavior.

Thanks for the tip, but I've done that before. But always had a problem.

I solved it as follows, not pretty but works!

       ---> by a WebCamChange


        ---> after  is WebCameraCameraDevicesInitialized event

        if camState = Front then
            WebCamera.CameraType := ctFront;
            WebCamera.CameraType := ctRear;



This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.