Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): switchCamera method was missing #14029

Merged
merged 2 commits into from May 23, 2024
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 8, 2024

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();
  • Start app
  • click on the window
  • click on "switch"
  • front facing camera show appear

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it works. I modified the code to toggle the cameras!

let showFront = true;
btn.addEventListener("click", function() {
    Ti.Media.switchCamera(showFront ? Ti.Media.CAMERA_FRONT : Ti.Media.CAMERA_REAR);
    showFront = !showFront;
});

APPROVED!

@cb1kenobi cb1kenobi merged commit bbde0c3 into master May 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants