red5 流媒体连接到 Flex

发布于 2025-01-03 07:58:59 字数 2481 浏览 2 评论 0原文

我成功安装了 red5,但是当我尝试连接到 red5 来传输视频时,连接失败。如果我使用 netstreaming(null),它可以工作,但是当我使用 red5 时,它就不行。

我使用以下代码连接流:

<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" creationComplete="init();">
<fx:Script>
    <![CDATA[
        import mx.utils.ObjectUtil;

        private var nc:NetConnection;
        private var ns:NetStream;
        private var video:Video;
        private var meta:Object;
        private var videoURL:String = "Fleximagteaser.flv";

        private var nc1:NetConnection;
        private var ns1:NetStream;
        private var video1:Video;
        private var meta1:Object;

        private function init():void {

            //video1
            var nsClient:Object = {};
            nsClient.onMetaData = ns_onMetaData;
            nsClient.onCuePoint = ns_onCuePoint;

            nc = new NetConnection();
            nc.connect("rtmp://localhost/demo");

            ns = new NetStream(nc);
            ns.play(videoURL);
            ns.client = nsClient;

            video = new Video();
            video.attachNetStream(ns);
            uic.addChild(video);
        }

        private function ns_onMetaData(item:Object):void {
            trace("meta");
            meta = item;
            // Resize Video object to same size as meta data.
            video.width = item.width;
            video.height = item.height;
            // Resize UIComponent to same size as Video object.
            uic.width = video.width;
            uic.height = video.height;
            panel.title = "framerate: " + item.framerate;
            panel.visible = true;
            trace(ObjectUtil.toString(item));
        }

        private function ns_onCuePoint(item:Object):void {
            trace("cue");
        }


    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox>
    <mx:Panel id="panel" visible="false">
    <mx:UIComponent id="uic" />
    <mx:ControlBar>
        <mx:Button label="Play/Pause" click="ns.togglePause();" />
        <mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
    </mx:ControlBar>
</mx:Panel>

</mx:VBox>
</s:Application>

有人可以帮忙吗?

I installed red5 successfully, but when I try to connect to red5 to stream a video, the connection fails. If I use netstreaming(null), it works, but when I use red5, it doesn't.

I use following code to connect the stream:

<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" creationComplete="init();">
<fx:Script>
    <![CDATA[
        import mx.utils.ObjectUtil;

        private var nc:NetConnection;
        private var ns:NetStream;
        private var video:Video;
        private var meta:Object;
        private var videoURL:String = "Fleximagteaser.flv";

        private var nc1:NetConnection;
        private var ns1:NetStream;
        private var video1:Video;
        private var meta1:Object;

        private function init():void {

            //video1
            var nsClient:Object = {};
            nsClient.onMetaData = ns_onMetaData;
            nsClient.onCuePoint = ns_onCuePoint;

            nc = new NetConnection();
            nc.connect("rtmp://localhost/demo");

            ns = new NetStream(nc);
            ns.play(videoURL);
            ns.client = nsClient;

            video = new Video();
            video.attachNetStream(ns);
            uic.addChild(video);
        }

        private function ns_onMetaData(item:Object):void {
            trace("meta");
            meta = item;
            // Resize Video object to same size as meta data.
            video.width = item.width;
            video.height = item.height;
            // Resize UIComponent to same size as Video object.
            uic.width = video.width;
            uic.height = video.height;
            panel.title = "framerate: " + item.framerate;
            panel.visible = true;
            trace(ObjectUtil.toString(item));
        }

        private function ns_onCuePoint(item:Object):void {
            trace("cue");
        }


    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox>
    <mx:Panel id="panel" visible="false">
    <mx:UIComponent id="uic" />
    <mx:ControlBar>
        <mx:Button label="Play/Pause" click="ns.togglePause();" />
        <mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
    </mx:ControlBar>
</mx:Panel>

</mx:VBox>
</s:Application>

Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑咖 2025-01-10 07:58:59
<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" creationComplete="init();">
<fx:Script>
    <![CDATA[
        import flash.globalization.Collator;

        import mx.utils.ObjectUtil;

        private var nc:NetConnection;
        private var ns:NetStream;
        private var video:Video;
        private var meta:Object;
        private var videoURL:String = "Fleximagteaser.flv";

        private var nc1:NetConnection;
        private var ns1:NetStream;
        private var video1:Video;
        private var meta1:Object;

        private function init():void {

            //video1


            nc = new NetConnection();
            nc.connect("rtmp");
            nc.client = this;
            nc.addEventListener(NetStatusEvent.NET_STATUS,onConnectionStatus);
            nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onErrorHandler);
            nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);



        }

        private function onConnectionStatus(event:NetStatusEvent):void
        {
            var nsClient:Object = {};
            nsClient.onMetaData = ns_onMetaData;
            nsClient.onCuePoint = ns_onCuePoint;
            ns = new NetStream(nc);
            ns.play("videourl");
            ns.client = nsClient;

            video = new Video();
            video.attachNetStream(ns);
            uic.addChild(video);


        }

        private function onErrorHandler(event:AsyncErrorEvent):void{}
        private function onSecurityError(event:SecurityErrorEvent):void{}



        private function ns_onMetaData(item:Object):void {
            trace("meta");
            meta = item;
            // Resize Video object to same size as meta data.
            video.width = item.width;
            video.height = item.height;
            // Resize UIComponent to same size as Video object.
            uic.width = video.width;
            uic.height = video.height;
            panel.title = "framerate: " + item.framerate;
            panel.visible = true;
            trace(ObjectUtil.toString(item));
        }

        private function ns_onCuePoint(item:Object):void {
            trace("cue");
        }

        public function onBWDone():void
        {}



    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox>
    <mx:Panel id="panel" visible="false">
        <mx:UIComponent id="uic" />
        <mx:ControlBar>
            <mx:Button label="Play/Pause" click="ns.togglePause();" />
            <mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
        </mx:ControlBar>
    </mx:Panel>

</mx:VBox>

<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" creationComplete="init();">
<fx:Script>
    <![CDATA[
        import flash.globalization.Collator;

        import mx.utils.ObjectUtil;

        private var nc:NetConnection;
        private var ns:NetStream;
        private var video:Video;
        private var meta:Object;
        private var videoURL:String = "Fleximagteaser.flv";

        private var nc1:NetConnection;
        private var ns1:NetStream;
        private var video1:Video;
        private var meta1:Object;

        private function init():void {

            //video1


            nc = new NetConnection();
            nc.connect("rtmp");
            nc.client = this;
            nc.addEventListener(NetStatusEvent.NET_STATUS,onConnectionStatus);
            nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onErrorHandler);
            nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);



        }

        private function onConnectionStatus(event:NetStatusEvent):void
        {
            var nsClient:Object = {};
            nsClient.onMetaData = ns_onMetaData;
            nsClient.onCuePoint = ns_onCuePoint;
            ns = new NetStream(nc);
            ns.play("videourl");
            ns.client = nsClient;

            video = new Video();
            video.attachNetStream(ns);
            uic.addChild(video);


        }

        private function onErrorHandler(event:AsyncErrorEvent):void{}
        private function onSecurityError(event:SecurityErrorEvent):void{}



        private function ns_onMetaData(item:Object):void {
            trace("meta");
            meta = item;
            // Resize Video object to same size as meta data.
            video.width = item.width;
            video.height = item.height;
            // Resize UIComponent to same size as Video object.
            uic.width = video.width;
            uic.height = video.height;
            panel.title = "framerate: " + item.framerate;
            panel.visible = true;
            trace(ObjectUtil.toString(item));
        }

        private function ns_onCuePoint(item:Object):void {
            trace("cue");
        }

        public function onBWDone():void
        {}



    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox>
    <mx:Panel id="panel" visible="false">
        <mx:UIComponent id="uic" />
        <mx:ControlBar>
            <mx:Button label="Play/Pause" click="ns.togglePause();" />
            <mx:Button label="Rewind" click="ns.seek(0); ns.pause();" />
        </mx:ControlBar>
    </mx:Panel>

</mx:VBox>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文