Welcome!

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

Reply
Developer
Posts: 306
Registered: ‎03-01-2011
My Device: Playbook (sim)

Cam does not work

Hi,

 

I want to display a video stream of the cam in my app. but on the devalpha A it doesn't work like on the playbook.

my code looks like this:

 


public function Main():void
{

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

textarea = new TextArea();
textarea.x = 10;
textarea.y = 10;
textarea.width = 748;
textarea.height = 280;
textarea.text = 'Cams: '+Camera.names[0]+' '+Camera.names[1];

cam = Camera.getCamera('1');

cam.setMotionLevel(1,10000);
cam.setMode(360, 240, 15, false);
cam.setQuality(0, 10);
cam.setKeyFrameInterval(30);

if (cam == null)
{

textarea.text = " No Cam ";

} else {

textarea.text = "Cam there";
}

addChild(textarea);

}



the cam is always null.. don't know why. anyone?

thanks

lrrm

..................................................................................................................................................................................................................

My App: Peg Solitaire

Need a designer? Drop me a line
New Contributor
Posts: 7
Registered: ‎01-21-2013
My Device: Z10 LE

Re: Cam does not work

Hi. I have the same problem. I just updated the AIR SDK (BlackBerry-Air-SDK-Installer-3.0.0-Win-201212071024) but I can not access the camera. I just updated the BB10DevAlpha to the 10.9.9.939 version (I think that this may be the problem). Any help it wil be very appreciated.

 

Thanks

 

Rodo

BlackBerry Development Advisor
Posts: 52
Registered: ‎04-01-2011
My Device: Torch, Playbook

Re: Cam does not work

Hi

 

was it working before? Also, did you check if you have the permission to use the camera added to your bar-descriptor.xml file?

 

<permission>use_camera</permission>

 

Cheers

 

 

 

---
Paulo Garcia
New Contributor
Posts: 7
Registered: ‎01-21-2013
My Device: Z10 LE

Re: Cam does not work

Thanks Paulo for respond. Yes, it worked perfectly before and that permission tag is active.
Contributor
Posts: 10
Registered: ‎06-28-2011
My Device: none

Re: Cam does not work

I think I had to put a delay in accessing the cam so try:

 

myTimer = new Timer(200, 1);
myTimer.addEventListener(TimerEvent.TIMER, init);
myTimer.start();

 

in your constructor...

BlackBerry Development Advisor
Posts: 52
Registered: ‎04-01-2011
My Device: Torch, Playbook

Re: Cam does not work

Hi

 

I just tried this small application:

 

	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.media.Camera;
	import flash.media.Video;

	public class CameraTest extends Sprite {
		
		private var video:Video;
		
		public function CameraTest() {
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			if( Camera.isSupported ) {
				var cam:Camera = Camera.getCamera('1');
				if (cam!=null) {
					cam.setMotionLevel(1,10000);
					cam.setMode(360, 240, 15, false);
					cam.setQuality(0, 10);
					cam.setKeyFrameInterval(30);
					
					video = new Video();
					video.x = 0;
					video.y = 0;
					addChild( video );
		
		                        video.attachCamera(cam);
		                        video.width = cam.width;
		                        video.height = cam.height;
				}
			}
		}
	}

 

and it works fine for me in a Dev Alpha device. Could you provide more details about what is not working for you (like cam always null, etc) ? Or maybe you could try the same code above so we can work on the same code base?

 

 

Thanks

 

 

---
Paulo Garcia
New Contributor
Posts: 7
Registered: ‎01-21-2013
My Device: Z10 LE

Re: Cam does not work

Paulo: thanks again for respond. I tried your code and it did not work. I reset the device and try to use the OS camera app and did not work too (first time run, it do not show any picture; second time run, a popup window telling that the camera it can not be started). So I think that may an OS problem. I am downloading right now the Autoload-DevAlpha from the site and I will try to update from the PC instead OTA like last time. 

 

New Contributor
Posts: 7
Registered: ‎01-21-2013
My Device: Z10 LE

Re: Cam does not work

Paulo: I just updated my DevAlpha again, this time with the autoload for Windows, and the camera is nos working. The first time I opened it, it seems like it is working but with no image, just the icons. When I closed and opened it again, a message that the camera can not be started is shown. So this is not a programming or AIR SDK problem, but it seems an OS problem. I really hope that could be an error of the OS into DevAlphas and not into the devices to be released next week.