Camera Tutorial, Part 8: Stop the camera

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

At the end of this part you will have

A complete ANE that starts the native camera, captures frames from it and finally stops it. Also a test app that takes the captured frames and displays them as live camera feed.

Time

6-7 minutes

Wait, have you done these first?

Step 1: Stop the native camera

What a surprise, we start by doing actual work!

In your Xcode project open CameraDelegate.m and add this method to the CameraDelegate class:

You’ll want to call stopCamera() from outside the CameraDelegate class, so make it public by adding its signature to CameraDelegate.h. This header should now look like this:

Step 2: Expose the call to ActionScript

You have technically done that, when you implemented the ASStopCameraPreview() function in Part 4, where you connected your native library to the camera. All that’s left to do there now is to get it to call CameraDelegate‘s stopCamera() method. In your Xcode project open CameraLibiOS.m, find ASStopCameraPreview() and add the call to it:

Step 3: Make sure your AIR Library makes the call

Hey, you implemented that in Part 3 of the tutorial, remember? In your AIR Library project, you should have this method in the CameraDriver class. Just make sure it’s there:

Step 4: Stop the camera from your app

In the app you made in the first part of the tutorial you should have a Stop button with a click handler function. Open your test app project and in CameraTutorialAppHomeView.mxml find that handler and make it call stopCameraPreview():

Step 5: What are you waiting for?

Go on, test it.

What’s next?

Next, give yourself a tap on the shoulder for sticking with this tutorial – that was a long drag, wasn’t it? No?

  • When you tested your ANE you probably noticed that the camera preview doesn’t orient itself when you turn your phone or iPad around. In the next post we’ll make a list of improvements and upgrades you can do to the code to customize it for your own app.
  • Here is the table of contents for the tutorial, in case you want to jump back.

 

Wait, want more features and Android support?

Check out the DiaDraw Camera Driver ANE.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Comments

    • Hristo

      Hi,

      Thanks for the kind words, we’re happy to hear that the tutorial series have been helpful.
      The last chapter has been on our TODO list for quite some time now, thanks for the reminder! We have been snowed under with work lately, but there will be an update to our tutorials soon, so stay tuned.

      Greetings,
      Hristo

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">