Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created March 6, 2019 17:14
Show Gist options
  • Save exclusiveTanim/1a424db4eb0a25f77d086da38a6289be to your computer and use it in GitHub Desktop.
Save exclusiveTanim/1a424db4eb0a25f77d086da38a6289be to your computer and use it in GitHub Desktop.
Front camera code for testing
var window = Ti.UI.createWindow({
backgroundColor : '#000'
});
// create button, register the modified click callback, add button to window
function addButton(title, clickCallback) {
var button = Ti.UI.createButton({
title : title,
width : '300',
height : '50'
});
button.addEventListener('click', function() {
Ti.Media.showCamera({
mediaType : Ti.Media.MEDIA_TYPE_PHOTO
});
clickCallback();
Ti.Media.vibrate();
});
window.add(button);
}
// camera with front specified after switching to back
// checks if switch function actually works, opposed to it being the default
addButton('Front Camera Test 2', function() {
Ti.Media.switchCamera(Ti.Media.CAMERA_BACK);
Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
});
window.open();
<key>NSCameraUsageDescription</key>
<string>Can we use your camera?</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Can we save to your library?</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Can we save to your library file?</string>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment