Skip to main content
September 3, 2011
Answered

Setting up Flash Stream to Media Server

  • September 3, 2011
  • 1 reply
  • 937 views

I have Adobe Media Server 4, and I am using Flash  Professional CS5.5 to create streaming application. For testing I use default Adobe Page where you can insert streamer url  and Stream name to connect to streaming source, for overview. It's that page at start up, where you have two blocks of videos, left  one to broadcast and right one to see stream.

Here is the AS3 code inside my application:

var bandwidth:int = 0; 
var quality:int = 50;
var camera:Camera = Camera.getCamera();

camera
.setQuality(bandwidth, quality);
camera
.setMode(430,320,15, true);

var video:Video = new Video();
video
.attachCamera(camera);
addChild
(video);
video
.width = 430;
video
.height = 320;

var nc:NetConnection = new NetConnection();
nc
.connect("rtmp://***");
nc
.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

function netStatusHandler(event:NetStatusEvent😞void{
   
if (event.info.code == "NetConnection.Connect.Success")
   
{
    label10
.text = 'Connected';
   
var ns:NetStream = new NetStream(nc);
    ns
.attachCamera(camera);
    ns
.publish("NewStream1", "live");
   
}

}

When I run this file I get "Connected" in label10, that means it's connected to rtmp server link.

When I insert this specific rtmp link and NewStream1 ( from  ns.publish("NewStream1", "live"); ) inside Adobe Default page, it  doesn't work... It connects, but it shows only blank black box.

And when I use that default page to stream, left broadcaster, it works great.

Also, I made my own watcher, and it connect too, but there is no data streaming.

Can someone help me with this, tell me what I am doing wrong?

Or can someone tell me how to test is data from camera sent to server?

Thank you.

    This topic has been closed for replies.
    Correct answer SE_0208

    Are you sure that when your client is running - Camera is not attached to any other client?

    1 reply

    SE_0208Correct answer
    Participating Frequently
    September 6, 2011

    Are you sure that when your client is running - Camera is not attached to any other client?

    September 6, 2011

    No, it's not attached...

    Here are some test facts:

    1. Media Server is up and running, everything works okay. I open default Media Server page, and in that INTERACTIVE tab I tested broadcaster and watcher, and it's all working okay.

    2. I write a new code for watcher, and stream camera from broadcaster on default Media Server page, and it's getting video, watcher code is working.

    3. I write a code that is attaching my camera to video object in application, and it shows my cam. So application have access to camera.

    4. When I use NetConnection to connect to rtmp it's return NetConnection.Connect.Success status. So it can connect to server with my app.

    5. When I TRY to publish camera with NetStream, and use mine or Media Server default page watcher none of those works.

    6. When I use only NetStream, and not attach camera to video element, camera turn on for few seconds, when it starts, and then turn off. Like NetStream is not using it after, only for few seconds.

    Here is the simpliest code:

    var cam1:Camera = Camera.getCamera();

    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://***");
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    function netStatusHandler(event:NetStatusEvent):void{

        if (event.info.code == "NetConnection.Connect.Success")
        {
           var ns:NetStream = new NetStream(nc);
                ns.attachCamera(cam1);
                ns.publish("myCamera","live");
        }

    }

    Can someone tell me what I am doing wrong?

    September 6, 2011

    I guess error was in

    var ns:NetStream = new NetStream(nc);

    should be out of function block, it needs to be defined with cam1, outside function...

    It's working now, I found source for another app online that has this and it turn out to be working...