How to swap Camera to front and back in Power Apps Canvas Apps

I am back with another blog on Power Apps and this time it is a really simple requirement.

There is Camera control on the form and using the Camera control, the user should be able to switch between back and front cameras.

A very generic requirement where the user can upload a pic from their mobile using their back camera or upload their selfie using the front camera.

For this, I created a icon which when clicked would swap the camera from front to back and vice versa.

On the ‘OnSelect‘ property of the control, I put the below formula

UpdateContext({cameraPosition: !cameraPosition})

Here “cameraPosition” is a local variable. Every time the swap icon is clicked, I reverse the value of “cameraPosition” property.

The final step is to set the Camera property of the Camera control to this variable.

swap camera from front to back and vice versa in Power Apps canvas apps

And now when you run this program, every time you click the icon, the camera shall switch from front to back and vice versa.

Hope this helped!

You might also like the below posts

Debajit Dutta
Business Solutions MVP