Problem Description
After I openCamera(), I try to takePicture() and following error appears in console:
[ERROR] : TiMedia: (KrollRuntimeThread) [1110,1110] Camera preview is not open, unable to take photo
But preview is opening and working well..
Hello,
We have tested this issue. Ti.Media.takePicture() only works on the overlay. But when we take the photo it continuously capture the photo on the galaxy s3 real device. It's a valid bug.
Steps to Reproduce
1. Create classic project.
2. Paste this file in app.js file.
var win1 = Titanium.UI.createWindow({
backgroundColor : '#fff',
layout : 'vertical'
});
var frmcamera = Ti.UI.createButton({
backgroundColor : '#ff0000',
title : 'Open Camera',
color : '#fff',
width : Ti.UI.SIZE,
height : Ti.UI.SIZE,
top : 10
});
frmcamera.addEventListener('click', function() {
fireUpTheCamera();
});
win1.add(frmcamera);
var overlay = Ti.UI.createView({
width : 80,
height : 80,
bottom : 20
});
// Create a Button.
var btn = Ti.UI.createButton({
title : 'Take',
height : 60,
width : 60
});
btn.addEventListener('click', function() {
Ti.Media.takePicture();
});
overlay.add(btn);
function fireUpTheCamera() {
Titanium.Media.showCamera({
success : function() {
console.log('taken');
},
saveToPhotoGallery : true,
autohide : false,
overlay : overlay,
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});
}
win1.open();
3. Run it in device attached to Android Monitor
Regarding to the source: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/ti/modules/titanium/media/MediaModule.java#L420 and https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/ti/modules/titanium/media/MediaModule.java#L293 takePicture() works only if overlay is set.