Created
April 27, 2011 21:24
-
-
Save jonalter/945245 to your computer and use it in GitHub Desktop.
Camera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Titanium.UI.setBackgroundColor('#000'); | |
| var win1 = Titanium.UI.createWindow({ | |
| title:'Tab 1', | |
| backgroundColor:'#fff' | |
| }); | |
| var camera_button = Titanium.UI.createButton ({ | |
| title:'Camera', | |
| height:60, | |
| bottom: 10, | |
| width:160 | |
| }); | |
| camera_button.addEventListener ('click', function(e) { | |
| Titanium.Media.showCamera ({ | |
| saveToPhotoGallery: true, | |
| allowEditing: true, | |
| success: function(event){ | |
| var a = Titanium.UI.createAlertDialog({ | |
| title: 'You did it!' | |
| }); | |
| a.show(); | |
| }, | |
| error: function(error){ | |
| var a = Titanium.UI.createAlertDialog({ | |
| title: 'Uh Oh...' | |
| }); | |
| if (error.code == Titanium.Media.NO_CAMERA || error.code == Titanium.Media.NO_VIDEO) { | |
| a.setMessage('Sorry, this device does not have a camera. You knew that, right?'); | |
| } | |
| else { | |
| a.setMessage('Unexpected error: ' + error.code); | |
| } | |
| a.show(); | |
| } | |
| }); | |
| }); | |
| win1.add(camera_button); | |
| win1.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment