Adobe Air - Choose webcam manually - actionscript-3

How to choose the webcam/camera manually in Adobe Air? In Flash it's working through this:
Security.showSettings(SecurityPanel.CAMERA);
Is there something like that in Adobe Air?
Thank

In the Adobe Air Player (up to 3.4) there is no equivalent of the Flash Player security panel that can be triggered with Security.showSettings(SecurityPanel.CAMERA);
If you want to let the user pick a camera, you will have to create some sort of menu by using the info from the Camera.names array. Then, you can assign the user's choice via code by using something like :
var cam:Camera = Camera.getCamera('1');
Important: contrary to what was said above you CANNOT specify the camera by name. The getCamera() function expects a string representation of the camera's index number as a parameter. This is weird behaviour but it's how it works. So if you want to retrieve the second camera, you will have to pass the string '1' to the getCamera() function.
If you try to set the camera by specifying it's name, the function will return null.

I don't think there is any feature that you can use to select camera in AIR.
Instead you have to do it by coding.
get list of cameras using Camera.names property and then get selected camera instance using Camera.getCamera("name of camera");
I think this is best way to Do it.

Do you really need that typical dialog?
You can set a camera manually first by showing a list by:
var cameraNames:Array = Camera.names;
And then.....
var cameraInstance:Camera = Camera.getCamera('selectedCameraName');

Related

In flash as3 webcam how to get newly connected webcam name at run-time?

I have a flash as3 based webcam video recorder that publishes the webcam video stream and to do this i am using the following codes :
var camera:Camera = Camera.getCamera(0);
var arr:Array = Camera.names;
if(camera != null)
{
videoWidth = topBorderContainer.width;
videoHeight = topBorderContainer.height;
camera.setMode(videoWidth, videoHeight, 30, false);
camera.setQuality(0, 100);
if (camera)
{
videoDisplay.videoObject.attachCamera(camera);
}
}
But problem is that if i am connecting a new document camera at run time and running my webcam tool then Camera.names returning the previously connected document camera name instead of returning the new document camera name.
And to get new document webcam name i have to restart my application again.
But i have no knowledge how to get newly connected document camera name at run time so if anybody know how to get the newly connected document camera name at run time please help me to solve.
It is very likely that you will not be able to pull the trick:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#getCamera()
"Scanning the hardware for cameras takes time. When the runtime finds at least one camera, the hardware is not scanned again for the lifetime of the player instance. However, if the runtime doesn't find any cameras, it will scan each time getCamera is called. This is helpful if the camera is present but is disabled; if your SWF file provides a Try Again button that calls getCamera, Flash Player can find the camera without the user having to restart the SWF file."
It is possible that Flash Player treats Workers (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Worker.html) as separate Flash Player instances and thus a new Worker would be able to access the renewed list of Cameras. You might want to try it.

Youtube Api As3 getCurrentTime

I am using the Youtube Api for AS3 and i used the function player.getCurrentTime so that I can get the current time of the video. I have been running into this error https://code.google.com/p/gdata-issues/issues/detail?id=6215 and I really need to get this fixed is there any solutions to this problem or a way around it. I am just trying to save the current video progress to a variable and access that variable later here is my code used for this function
mis_player = new my_players(vidSource, mis_players.my_play.getCurrentTime());
and here is the code used for using the var both work fine at first then display the second value as the end of the video
my_play.seekTo(currTime1)
I figured it out, by sending the variable through the function I was able to pass the variable through to the function.

How to record video using the as3 camera class

I'm trying to add video recording into a mobile app I'm building. But am struggling with the recording part. So far I have got the camera class displaying in a video object with the code below.
private function init():void
{
var camera1:Camera = Camera.getCamera();
trace(Camera.names);
if (camera1)
{
var ui1:UIComponent = new UIComponent();
var video:Video = new Video (320, 240);
camera1.setMode(320, 240, 24);
camera1.setQuality(0, 100);
video.attachCamera(camera1);
ui1.addChild(video);
cameraGroup1.addElement(ui1);
}
}
From what I understand you can use the cameraUI class instead to achieve the recording part and add it to the library but it would mean using the default camera application when I would rather use my own. I imagine recording using the camera class would require a tick to grab each frame and then something like the videoFrame event but could really use some code or a point in the right direction.
Thanks in advance.
Best way to record using the Flash or AIR application is Media Server. You can connect your application with Media Server (Flash Media Server / Red5 / any other Media Server which is providing Media Recording and Publishing.) and publish your stream for recording.
Second way, I need to search out the code but logically I can say answer. We need to convert Camera stream buffer in to the binary data and we need to save binary data as video file o File system.
For that you can write down some code in ActionScript and need to write down some code in the Native Application as Native Extension.

create (webcam capture like youtube) in my website

I have a website working the same as youtube. At this moment I am trying to create a video image captured by WEBCAM.
The video image should be saved on my computer (by FLV format) first and then if the user is satisfied, he or she can upload it on the server
I am trying to use Actionscript3 in Adobe flash CS5 and Flash media server4
1- How can I do that?
2- Is the flash media server needed?
Please pay attention that we would like to allow the user to save video on his/her computer and then be able to uploaded to the server.
Many thanks.
Assuming the computer can take the overhead of doing the encoding on the fly (or has enough memory to buffer the data then can run the data through an encoding process) then the library mentioned in the SO answer here should work:
Encode video from any format to .flv format in AS3
I believe the Flash media server would only really be necessary in this case for broadcast.
Pseudocode example
private var cam:Camera;
public function Whatever()
{
//In constructor
addEventListener(Event.ENTER_FRAME, grabFrame);
cam = Camera.getCamera();
if (cam != null)
{
var vid:Video = new Video(cam.width, cam.height);
vid.attachCamera(cam);
addChild(vid);
}
}
private function grabFrame(event:Event):void
{
var bd:BitmapData = new BitmapData(cam.width, cam.height)
bd.draw(vid);
//now the BitmapData has a frame of the video, at this point you also
//would want to capture the audio then use the FLV class in the library
}
You can also check out using Red5 as an alternative open source video stream recorder.
http://distriqt.com/post/493
Cheers

simple video chat using as3

I'm trying to make a simple video chat using Flex framework and red5 server. It's an application with 2 video displays. With connection to the server more or less figured out. However, I do not understand how to transfer user1 stream to user2.
Here is functions i use to transfer webcam image to the server and to get the stream.
public function appendStream(connection:NetConnection):void {
myNetStream = new NetStream (connection);
myNetStream.attachAudio(cameraVideo.getMic());
myNetStream.attachCamera(cameraVideo.getCam());
myNetStream.publish("videochat" , "live");
}
public function getStream(connection:NetConnection):Video {
guestNetStream = new NetStream(connection);
video2.attachNetStream (guestNetStream);
guestNetStream.play("videochat");
return video2;
}
As you can see, i am getting my own stream.
Is it possible to solve the problem by flex, or I need programming on the server side?
You dont need separate rooms, simply use unique stream names for each client. The ez way is to create your steam names ahead of time and pass them to your swf via flashvars; that way you dont have to pair them with some other complicated scheme.
For a bit more background in red5, a room is a type of scope and a scope can contain other scopes which includes broadcast scopes, shared object scopes, and rooms. There is no limit on the number of these scopes other than the amount of RAM on the server itself.
You need to have two "rooms" instead of one "videochat". User1 must publish to "videochat1" and stream from "videochat2". Vice versa for user2.
And please remove Flex mention here since there's nothing related to Flex UI framework here