0

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

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

1 回答 1

0

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

于 2012-05-18T05:53:11.210 回答