Question

This error gets thrown on ios7, I've built a small example Camera app in Titanium here is the code:

index.js

var overlay = Ti.UI.createView({
    width: Ti.UI.FILL,
    height: Ti.UI.FILL,
    backgroundColor: 'transparent'
});

var takePhotoBtn = Ti.UI.createButton({
    width: '200dp',
    height: '60dp',
    bottom: '100dp',
    backgroundColor: '#FFF'
});

var btnLbl = Ti.UI.createLabel({
    text: 'Take Photo'
});

takePhotoBtn.addEventListener('click', function(e){
    Ti.Media.takePicture()
});

takePhotoBtn.add(btnLbl);
overlay.add(takePhotoBtn);

$.back.addEventListener('click', showCamera);

$.index.open();

function showCamera(){
    Ti.Media.showCamera({
        success: function(event){
            var imageData = event.media;
            $.resultImg.setImage(imageData);
            Ti.Media.hideCamera();
        },
        error: function(error){
            Ti.API.info('Error: ' + JSON.stringify(error));
        },
        overlay : overlay,
        saveToPhotoGallery: false,
        allowEditing: false,
        mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO],
        showControls : false,
        autohide : false,
        //make the picture inside the camera smaller so that we 
        //can than place an overlay around it
        transform: Ti.UI.create2DMatrix({
            scale : 0.5
        })
    });

    Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);   
}

and in the index.xml

<Alloy>
    <Window class="container">
        <Button id="back" title="Start camera"/>
        <ImageView id="resultImg"/>
    </Window>
</Alloy>

It does not happen every time you snap the picture but maybe every 10 times. Please help!!!

Was it helpful?

Solution

When you are taking multiple pictures in a row, iPhone is out of memory processing previous ones. When you are using Objective-C you can add observer with this code:

[[NSNotificationCenter defaultCenter] addObserver:self
                                     selector:@selector(cameraIsReady:)
                                         name:AVCaptureSessionDidStartRunningNotification object:nil];

However, this API is not implemented in Titanium, so right now to solve this problem you have to catch this error wait couple seconds showing user quick information and then try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top