来自网络摄像头的直播视频使用FMS&柔性

时间:2012-05-17 22:31:58

标签: flex video flash-builder flash-media-server

我正在尝试使用FMS从网络摄像头直播视频。我已经在这里编写了我正在尝试使用的代码,但是我收到了这个错误。请指导我正确的解决方案。我非常感谢能得到的所有帮助。

错误: 错误#2044:未处理的AsyncErrorEvent:。 text =错误#2095:flash.net.NetConnection无法调用onBWDone回调。 error = ReferenceError:错误#1069:在vv上找不到属性onBWDone且没有默认值。     at vv / button2_clickHandler()[]     在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>

1 个答案:

答案 0 :(得分:0)

为什么不使用Flash Media Encoder将视频流式传输到FMS。 您可以使用Flash Media Encoder应用程序或控制台命令。