tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

fix(android): switchCamera method was missing #14029

Closed m1ga closed 6 months ago

m1ga commented 6 months ago

In the CameraX PR I've accidentally removed the normal overlay switchCamera method after adding the code for the CameraX switchCamera:

Old diff: https://github.com/tidev/titanium-sdk/pull/12395/files#diff-e4ed05264b4abd4321aa6dc1038e0d1e5151cecb0deca2057315ccfff9e8c296L1421-L1426

Test:

var win = Ti.UI.createWindow();
win.addEventListener("click", function() {
    Ti.Media.requestCameraPermissions(function(e) {
        if (e.success) {
            var overlay = Ti.UI.createView();
            var btn = Ti.UI.createButton({
                bottom: 0,
                title: "switch"
            })
      overlay.add(btn);
            Ti.Media.showCamera({
                overlay: overlay
            });

            btn.addEventListener("click", function() {
                Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
            })
        }
    });
})
win.open();