0

I'm trying to live stream my video from webcam using FMS. I have written the code here which I am trying to work with, but I get this error. Please guide me to right solution. I really appreciate all the help I can get.

Error: Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on vv and there is no default value. at vv/button2_clickHandler()[] at vv/___vv_Button2_click()[]

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;



            var camera:Camera = Camera.getCamera();
            var localCam:Video = new Video(420,313);
            protected function video_d_creationCompleteHandler(event:FlexEvent):void
            {
                // TODO Auto-generated method stub

                if (camera) {
                    //var localCam:Video = new Video(280,150);
                    localCam.attachCamera(camera);
                    localCam.smoothing = true;
                    //localCam.
                    video_d.addChild(localCam);
                } else {
                    Alert.show("You don't seem to have a camera.");
                }
            }


            protected function button2_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                lsfmspanel.visible = true; 

                var nc:NetConnection = new NetConnection();
                nc.client = this;
                nc.connect("rtmp://localhost/live");
                nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

                function netStatusHandler(event:NetStatusEvent):void {
                    switch (event.info.code) {
                        case "NetConnection.Connect.Success":
                            var ns:NetStream = new NetStream(nc,NetStream.CONNECT_TO_FMS);
                            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onBWDone);
                            ns.attachCamera(camera);
                            ns.publish("livestream", "live");

                            break;
                        case "NetStream.Play.StreamNotFound":
                            trace("Unable to locate video: ");
                            break;
                    }
                }

                function asyncErrorHandler(event:AsyncErrorEvent):void { Alert.show("E." + event.text); }
                function onBWDone(event:AsyncErrorEvent):void{
                    trace("onBWDone");
                }

            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Panel x="5" y="9" width="448" height="365" title="Live Stream">
        <s:VideoDisplay id="video_d" x="10" y="9" width="426" height="313"
                        creationComplete="video_d_creationCompleteHandler(event)"/>
    </s:Panel>
    <s:Panel x="462" y="9" width="448" height="365" title="Live Streaming From FMS" visible="false" id="lsfmspanel">
        <s:VideoDisplay id="livestream" x="10" y="9" width="426" height="313" source="rtmp://localhost/live" autoPlay="true"/>
    </s:Panel>
    <s:Button x="105" y="382" label="Start Streaming" click="button2_clickHandler(event)"/>

</s:Application>
Bilal Ahmad
  • 191
  • 1
  • 2
  • 17

1 Answers1

0

Why not using the Flash Media Encoder to stream the video to the FMS. You can use the Flash Media Encoder application or console commands.

Horonchik
  • 477
  • 2
  • 11
  • Thank you Horonchick. I'm going to look into FMS with Flash Encoder and try to make it work but just curious.... Do I have to...? I mean will the method I'm trying to use not work or it is not recommended ? Thanks – Bilal Ahmad May 19 '12 at 00:59
  • Sorry, I don't familiar with this method. – Horonchik May 19 '12 at 10:42
  • ok thanks for the help. Any link that you can point me to for FME please? – Bilal Ahmad May 19 '12 at 14:35