Titanium.Media.showCamera({overlay:overlay,showControls:false,success:true,cancel:true,error:true});
overlay and showControls don't behave as expected
In fact, they don't seem to work at all on android.
Extremely frustrating this is. Tried everything I can think of I have!
Below is a code snippet I've been working with. I've tried everything I can think of to get this to work! I'm on android (HTC EVO & AVD Emulator). I've tried this with the android SDK 2.0 - 2.2 and the Titanium SDK 1.2 - 1.5, and all the combinations there in.
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();
}
});
The code you see is basically a stripped down version of the KitchenSink: cameraVideo.js. In fact, it is nearly identical to every other example I've seen people suggest.
I have a Gist page with the code I'm working with:
https://gist.github.com/731401
Any feedback with code snippets or suggestions would be appreciated. I'll make sure that the winner's code is in here as the accepted answer and I'll update Gist with the code that works.
1 Answer
-
Accepted Answer
Android doesn't support overlay at this point. It's commented out in the examples in KS so it only shows for iPhone.