Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Automatically takePicture?

Is there any way to trigger takePicture without the user having to intervene?

Here's my code
http://pastie.org/1103252

All I want to do is to show the camera, wait 2 seconds and then automatically shoot. I know this is possible natively because there are apps that are timer photo apps.

http://www.ofzenandcomputing.com/zanswers/1534

— asked August 19th 2010 by Kevin Lim
  • camera
  • mobile
  • showcamera
  • takepicture
0 Comments

6 Answers

  • same question here. The documentation says it should work with takePicture but on Android it will show the camera and you have to take the picture yourself. Is it broken?

    — answered May 29th 2011 by Michael G.
    permalink
    0 Comments
  • I am curious to this functionality as well. My use case is that I am needing to automatically take a sequence of pictures: show camera viewfinder, snap the photo automatically, show the result for a couple seconds save the photo then repeat for a specified number of times or until event.

    — answered July 26th 2011 by Jerod Fritz
    permalink
    0 Comments
  • Did you ever solve this? I'm looking to do something similar. I want the camera to take a picture under my control and not have any user intervention.

    — answered February 26th 2012 by Manuel Flores
    permalink
    0 Comments
  • hey did you solve it?i have to do the same thing!

    — answered August 7th 2012 by Cristina Nardin
    permalink
    0 Comments
  • No, I never did. I believe it's against Apple rules to have a picture taken without some user interaction. As a result, I abandoned my idea.

    — answered August 8th 2012 by Manuel Flores
    permalink
    2 Comments
    • var timer1 = setInterval(function(){
          Titanium.Media.takePicture();
      },2000);
      
      var picsTaken = 1;
      Titanium.Media.showCamera({
          saveToPhotoGallery: true,
          success: function(event)
          {    
              var img = event.media;
              imgName = day + '.' + month + '.' + year + '-' + picsTaken +  '.png';
              imgFile = Titanium.Filesystem.getFile(imgDir.nativePath,imgName);
              imgFile.write(img);
              alert('File is saved in ' + imgFile.nativePath);
              picsTaken++;
              if(picsTaken>5)
              {
                  picsTaken = 1;
              }
          },
          cancel: function(){},
          error: function(error)
          {
              var a = Titanium.UI.createAlertDialog({title:'Video'});
              if (error.code == Titanium.Media.NO_VIDEO)
              {
                  a.setMessage('Device does not have video recording capabilities');
              }
              else
              {
                  a.setMessage('Unexpected error: ' + error.code);
              }
              a.show();
          },
          overlay : overlay,
          showControls: false,
          mediaTypes: Titanium.Media.MEDIA_TYPE_PHOTO,
          autohide: false
      });
      

      — commented August 13th 2012 by Cristina Nardin
    • Thank you for the solution. I'll try it out

      — commented August 13th 2012 by Jerod Fritz
  • Oh wait, it wasn't the picture taking that was the problem, it was the sending of a picture via email with no user interaction that was the problem.

    — answered August 27th 2012 by Manuel Flores
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.