Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel
Accepted Solution

how to open camera in playbook

Hello friends, 

please help me out by telling how can i open the camera in playbok by code.. 

i need to open camera then click a pic which i want to display in my application 

Thank you.


Regular Contributor
Posts: 53
Registered: ‎04-28-2011
My Device: Playbook
My Carrier: Not Specified

Re: how to open camera in playbook

You should use the CameraUI class. Check out this link:



Playbook App: Car Crash


Posts: 20
Registered: ‎03-22-2011
My Device: playbook and 9800
My Carrier: airtel

Re: how to open camera in playbook

use this mxml and action script code

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Home">
<fxSmiley Very Happyeclarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fxSmiley Very Happyeclarations>
<fxSmiley Frustratedcript&gt;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.*;
import flash.geom.Matrix;
import flash.media.Camera;
import flash.media.Video;
import flash.system.Security;
import flash.system.SecurityPanel;

public static const DEFAULT_CAMERA_WIDTH : Number = 320;
public static const DEFAULT_CAMERA_HEIGHT : Number = 240;
public static const DEFAULT_CAMERA_FPS : Number = 30;

private var video:Video;
private var camera:Camera;

private var _cameraWidth : Number;
private var _cameraHeight : Number;

public function CameraStream() {
camera = Camera.getCamera();


if(camera != null) {
camera.setMode(_cameraWidth, _cameraHeight, DEFAULT_CAMERA_FPS)
video = new Video(camera.width, camera.height);
else {
trace("Go get a camera.");

public function getSnapshotBitmapData():BitmapData {
var snapshot:BitmapData = new BitmapData(_cameraWidth, _cameraHeight);
snapshot.draw(video,new Matrix());

return snapshot;

public function getSnapshot() {
var bitmap : Bitmap = new Bitmap(getSnapshotBitmapData());

protected function b1_clickHandler(event:MouseEvent):void

protected function b2_clickHandler(event:MouseEvent):void


protected function b3_clickHandler(event:MouseEvent):void
// TODO Auto-generated method stub

</fxSmiley Frustratedcript&gt;
<s:Button id="b1" x="34" y="188" label="Button" click="b1_clickHandler(event)"/>
<s:Button id="b2" x="199" y="188" label="Button" click="b2_clickHandler(event)"/>
<s:Button id="b3" x="354" y="188" label="Button" click="b3_clickHandler(event)"/>
<s:Label id="l" x="400" y="400" />


there are two buttons ,when u click button b1 it will access camera and when u click button b2 it will capture the screen
New Contributor
Posts: 7
Registered: ‎05-10-2011
My Device: Playbook
My Carrier: Air Developer

Re: how to open camera in playbook

Someone managed to operate the camera? CameraUI is only supported on Air2.7,Playbook runs only 2.5, am I right?

Implementing the traditional way, as quoted coll_hupar, did not workCamera.length shows me that there are two cameras, but when I attach an object to any video, nothing happens.

Could anyone help me?

Posts: 15
Registered: ‎05-04-2011
My Device: 9700
My Carrier: Rogers

Re: how to open camera in playbook

Don't know about CameraUI but it is definitely possible to use Camera and Video. What is the code you are using ? Did you add the appropriate permission to your blackberry-tablet.xml ?

Posts: 20
Registered: ‎03-22-2011
My Device: playbook and 9800
My Carrier: airtel

Re: how to open camera in playbook

this metohod will work you have to set appropriate permission to your blacckberry-tablet.xml(as suggested by andrew 99) ,and this will not work in simulator ,for permission see sdk release notes