开发者

Save image to photoGallery

var _picsTaken = 0;
var timer = {};




Titanium.Media.showCamera ({

saveToPhotoGallery: true,
allowEditing: false,
autohide:false, //Important!

success: function(event){



timer = setInterval(function(){
        Ti.Media.takePicture();
        if(_picsTaken++ > 5){
            clearInterval(timer);
            _picsTaken = 0;
        }
    }, 5000);


},

error: function(error){
    var a = Titanium.UI开发者_如何学JAVA.createAlertDialog({
        title: 'Camera'
    });
    if (error.code == Titanium.Media.NO_CAMERA || error.code == Titanium.Media.NO_VIDEO) {
        a.setMessage(L('no_camera'));
    }
    else {
        a.setMessage('Unexpected error: ' + error.code);
    }
    a.show();
},


cancel:function()
{
    Titanium.include('db.js');
},
});

I am trying to make an ios based app on titanium studio(1.7). What I am trying to do here is click pictures continuously automatically every 5 seconds and save it. But this code only saves the first picture. I have tried to change a lot in the code, but nothing seems to work. Please help me in this regard. I would really appreciate any sort of help. Thanks in advance.


Try this:

success: function(event){
    Ti.Media.saveToPhotoGallery(event.media);
    timer = setInterval(function(){
        Ti.Media.takePicture();
        if(_picsTaken++ > 5){
            clearInterval(timer);
            _picsTaken = 0;
        }
    }, 5000);
},
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜