Home | Search | Login | RSS
We have 1073 members and counting!
Next Page

1

Previous Page

Thread: Publish Camera in AS3 with Flex

Created on: 09/10/11 04:37 AM

Replies: 6

Alexw





Joined: 01/31/08

Posts: 14

Publish Camera in AS3 with Flex
09/10/11 4:37 AM

Hi there,

I'm trying to publish my camera to Flash Media Server 4 and on screen.
I tryd the followed code:

view plain print about
1
2                cam = Camera.getCamera();
3                vid = new Video(320, 240);
4                vid.x = 10;
5                vid.y = 10;
6                vid.attachCamera(cam);
7                addChild(vid);
8                
9                ns = new NetStream(nc);
10                ns.attachCamera(cam);
11                ns.publish("test", "live");

and before all functions begin:

view plain print about
1
2            private var nc:NetConnection;
3            private var ns:NetStream;
4            
5            private var cam:Camera;
6            private var vid:Video;

But i get the following error:
"Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one."

Is it possible to get an tutorial like you did before only then in AS3 with Flex (FlashBuilder)?

Thanks in advanced,
Alexw

Link | Top | Bottom

Alexw





Joined: 01/31/08

Posts: 14

RE: Publish Camera in AS3 with Flex
09/10/11 7:46 AM

Ok, now i got the followed code:

view plain print about
1
2                cam = Camera.getCamera();
3                
4                ns = new NetStream(nc);
5                ns.addEventListener(NetStatusEvent.NET_STATUS, onStreamStatus);
6                ns.attachCamera(cam);
7                ns.publish("test", "live");
8                
9                nsPlayer = new NetStream(nc);
10                nsPlayer.play("test");
11                
12                vid = new Video(416, 309);
13                preview.addChild(vid);
14                vid.attachCamera(cam);
15                //vid.attachNetStream(ns);

With the code above i can see the camera but I'm unable to see the camera at the admin console in debug mode. Also if i try "vid.attachNetStream(ns);" then i also got no display.

So with other words, I'm doing something wrong or i forgot something to publish the camera to the server.

Thanks again,
Alexw

Link | Top | Bottom

Alexw





Joined: 01/31/08

Posts: 14

RE: Publish Camera in AS3 with Flex
09/10/11 10:04 AM

Ok, fixed it with the followed code:

view plain print about
1
2                cam = Camera.getCamera();
3                
4                /* BEGIN PUBLISH STREAM */
5                ns = new NetStream(nc);
6                ns.addEventListener(NetStatusEvent.NET_STATUS, onStreamStatus);
7                ns.publish("test", "record");
8                
9                ns.attachCamera(cam);
10                /* END PUBLISH STREAM */
11                
12                /* BEGIN PLAYING STREAM */
13                nsPlayer = new NetStream(nc);
14                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onStreamStatus);
15                nsPlayer.play("test");
16                
17                vid = new Video(416, 309);
18                preview.addChild(vid);
19                vid.attachNetStream(nsPlayer);
20                /* END PLAYING STREAM */

Link | Top | Bottom

Alexw





Joined: 01/31/08

Posts: 14

RE: Publish Camera in AS3 with Flex
09/10/11 11:54 AM

Oh well....everything works fine, only...when the camera is published the FPS always drops from 15 to 3. And i'm hosting it locally, so it should be constant at 15. Because that's the default.

Any solution?

Thanks,
Alexw

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: Publish Camera in AS3 with Flex
09/11/11 9:56 AM

I've been meaning to redo a bunch of tutorials for AS3 and Flex actually, great reminder.

Looks like you got it there. As for the FPS, I suspect flash might be struggling a bit with that size? maybe.. other than that, how do you know what FPS is making it through?

I would set the quality for the camera explicitly if I were you, see if you see a change there. Also, set the mode properly too, there is a default but it's best to tell Flash what to capture the camera at. That should all help a bit I would think.

Link | Top | Bottom

Alexw





Joined: 01/31/08

Posts: 14

RE: Publish Camera in AS3 with Flex
09/12/11 3:58 AM

Well, I'm running it localhost.
So it should handle the quality maxed out. I tryd lowering it yes, but no affect.
But i'm using the variable: cam.currentFps, to get the FPS.

One thing, why can't I view the camera at the Admin Console in debug mode?
* Last updated by: Alexw on 9/12/2011 @ 4:19 AM *

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: Publish Camera in AS3 with Flex
09/13/11 9:51 AM

Try setting up the camera with basic settings, like a size of 160 x 120, fps 15 and quality of 90 with bandwidth at 0. Change your video size to that and see how it goes.

As for viewing the camera in the admin console, you have to click the "view stream" button. Sometimes it takes a few clicks.. I don't know why.

Link | Top | Bottom

Next Page

1

Previous Page

New Post

Please login to post a response.