Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Adobe AIR Developer Center / AIR Quick Starts for ActionScript developers /

Capturing video input in a mobile AIR application

by Sunil Bhaskaran

Sunil Bhaskaran

Content

  • Creating a Camera object
  • Declaring Android permission to use device camera
  • Attaching a Camera object to a Video object
  • Where to go from here

Modified

10 October 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Adobe AIR Flash Builder Flash Professional mobile video

Requirements

Prerequisite knowledge

Familiarity with ActionScript 3.

 

Additional Requirements

  • Android device

User level

Intermediate

Required products

  • Flash Builder (Download trial)
  • Flash Professional CS5 (Download trial)

Sample files

  • VideoInputTest.zip
  • VideoInputTest-android-apk.zip

You can use the Camera class to capture video from the camera on a mobile device. You can display the camera video using the Video class. This article covers:

  • How to create a camera object
  • How to declare Android permission to use device camera
  • How to attach the camera to a Video object

Creating a Camera object

Get a reference to the Camera object using the camera.getCamera() method.  The getCamera() method returns a Camera object if a camera is available and returns null otherwise.  On Android, only one camera is supported.

The code below creates a camera object. If the Camera object returns null, the code traces a message, "No camera is installed." 

private var camera:Camera = Camera.getCamera(); if (camera == null) { trace "No camera is installed."); } else { trace("Camera is installed."); camera.setMode( 800, 400, 15, true ); }

The default size of the camera output can be small. Call the setMode() method to set the desired video resolution.

The hardware camera maintains a natural landscape orientation. When you use the Camera class, set the landscape aspect ratio for your application as well. You can set the aspect ratio to landscape in the application descriptor. You can also set it at runtime using the stage aspectRatio property. Avoid enabling the autoOrients setting in the application descriptor. If enabled, the device switches to the portrait aspect ratio when the user rotates the phone.

Declaring Android permission to use device camera

To access device camera, provide the permission to use camera in Android Manifest. In the application descriptor, under <android>, add the following:

<manifestAdditions> <![CDATA[ <manifest> <uses-permission android:name="android.permission.CAMERA"/> </manifest> ]]> </manifestAdditions>

Attaching a Camera object to a Video object

The following method creates a Video object with the same width and height as of the device camera. To display video, attach the Camera object to the Video object. Then, add the Video object to the display list using the addChild() method.

private function connectCamera():void { var video:Video = new Video(camera.width, camera.height); video.x = 10; video.y = 10; video.attachCamera(camera); addChild(video); }

Where to go from here

In this article, you learned about creating a Camera object and providing permission to use the device camera. You also learned about attaching a Camera object to a Video object to capture a video input. Use the Camera and Video classes in AIR to build complex applications.

For more information, refer to the online documentation, ActionScript 3 API Reference for the Adobe Flash Platform.

More Like This

  • Capturing soft key input
  • Using the StageWebView class
  • Using the tel: and sms: URIs in a mobile phone application
  • Using the Adobe AIR Geolocation APIs on Android

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement