Created
December 7, 2010 03:16
-
-
Save jgyurkovitz/731401 to your computer and use it in GitHub Desktop.
My trials with trying to get my camera app to work on android.
This file contains 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
/*********************************************** | |
** Version that should work but doesn't ** | |
***********************************************/ | |
Titanium.UI.setBackgroundColor('#000'); | |
var cameraWindow = Titanium.UI.createWindow({ | |
backgroundColor:'#FFF' | |
}); | |
var startVideoButton = Titanium.UI.createButton({ | |
bottom:10, width:120, height:40, | |
title:'Start Video' | |
}); | |
var overlay = Titanium.UI.createView(); | |
overlay.add(startVideoButton); | |
Titanium.Media.showCamera({ | |
overlay:overlay, | |
showControls:false, | |
success:function(event) | |
{ | |
Ti.API.debug("video was taken"); | |
}, | |
cancel:function(){}, | |
error:function(error) | |
{ | |
var a = Titanium.UI.createAlertDialog({title:'Camera'}); | |
if (error.code == Titanium.Media.NO_CAMERA) | |
{ | |
a.setMessage('Please run this test on a device with a camera'); | |
} | |
else | |
{ | |
a.setMessage('Unexpected error: ' + error.code); | |
} | |
a.show(); | |
} | |
}); | |
/********************************************************************* | |
** Testing to make sure that I can actually create the button ** | |
*********************************************************************/ | |
Titanium.UI.setBackgroundColor('#000'); | |
var cameraWindow = Titanium.UI.createWindow({ | |
backgroundColor:'#FFF' | |
}); | |
var startVideoButton = Titanium.UI.createButton({ | |
bottom:10, width:120, height:40, | |
title:'Start Video' | |
}); | |
var overlay = Titanium.UI.createView(); | |
overlay.add(startVideoButton); | |
cameraWindow.add(overlay); | |
cameraWindow.open(); | |
//This does what you would expect it to do. Show a window with a simple button on it. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment