generating a camera event

generating a camera event

hi there,

I'm writing a cross-platform App with XDK new and am trying to generate an event to turn the camera off, but am having no luck.

The code is something like this:

    intel.xdk.camera.takePicture(70, false, "jpg");  turn camera on

    // set a timer using an interval 
    timerHandle = setInterval(function(){cameraStop();}, 10000);   // give the user 10s to take a picture

...

// if they haven't taken the picture after 10s, turn off the camera by generating a camera event

 

function cameraStop() {
    clearInterval(timerHandle);    // stop the timer

    var stopCameraEvent = document.createEvent("Events"); 

   stopCameraEvent.initEvent("intel.xdk.camera.picture.cancel", true, false);  // event type, bubbling and non-cancellable

    dispatchEvent(stopCameraEvent);       

}

 

Does anyone have any experience with turning off the camera and/or generating events from within XDK?  Please let me know any pointers, solutions, tips...  

 

thank you,

Terence

 

 

 

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

to be obvious, a comment was forgotten in this entry (but not in the code) at:

  intel.xdk.camera.takePicture(70, false, "jpg");  turn camera on

should be:

  intel.xdk.camera.takePicture(70, false, "jpg");  // turn camera on

 

 

Best Reply

I don't think it's possible because what you've done when you initiate use of the camera is fire an "intent" that starts up the default camera application on the device. When the user exits from the camera application it returns you to the app that cause the camera app to start. In other words, the camera app is not part of your app, it is providing a service to your app and has control of the UI while it provides that service.

That's a shame.  I guess I may have to go "native" on this one.

Thanks for your help Paul,

Terence

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today