Custom camera with AVFoundation?

I followed Kavsofts tutorial for custom camera using SwiftUI and AVFoundation. Problem is I could only use the back camera. I want to be able to switch between back and front camera. It would also be nice to be able to record. I want to create a custom camera such as Snapchat, instagram, twitter and Facebook has, but I can’t find any YouTube tutorials that covers it all.

Does someone know about any tutorials or corses for this? Can you even do this on SwiftUI? Could someone point me in the right direction?

Trying to do something similar as well. Not gonna lie, it’s difficult!

We got something working by following along this article:

We got it working but don’t ask me to explain what’s going on though. I’m still trying to fully understand it myself haha

And for switching front and back camera check this out :

Thank you!