Skip to main content
Inspiring
November 15, 2011
Question

can netstream play and publish simultaneoulsy?

  • November 15, 2011
  • 1 reply
  • 807 views

i've created a sub-folder called dvr under fms 4.0 applications. i made a test of playing a video named sample.flv then at the same time i publish it to the same fms 4.0 server with a different video name: "mergedVideo".

the asc at the fms server as following:

application.onAppStart = function()

{

    trace("app start : " + application.name);

}

application.onConnect = function(clientObj)

{

    trace("the client is accepted is : " + clientObj);

    this.acceptConnection(clientObj);

}

application.onPublish = function (clientObj, streamObj)

{

    trace("onPublish stream: "+streamObj.name);

    streamObj.record();

}

the client-side code like this:

<![CDATA[

            import mx.core.UIComponent;

            private var _nc:NetConnection;

            private var _ns:NetStream;

            private var vid:Video;

            private var ui:UIComponent;

            private function init():void

            {

                //create net connection

                _nc = new NetConnection();

                _nc.client = this;

                _nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

                _nc.connect("rtmp://127.0.0.1/dvr");

            }

           

            private function onNetStatus(event:NetStatusEvent):void

            {

                if(event.info.code.indexOf("Success"))

                {

                    trace("connect success...");

                    createNetStream();

                }

            }

           

            private function createNetStream():void

            {

                _ns = new NetStream(_nc);

                var clientobj:Object = new Object();

                clientobj.onMetaData = function():void{};

                _ns.client=clientobj;

                vid = new Video();

                vid.attachNetStream(_ns);

                ui = new UIComponent();

                ui.width = 400;

                ui.height = 300;

                ui.addChild(vid);

                this.addElement(ui);

                _ns.play("sample");

                _ns.publish("mergedVideo", "record");

            }

           

        ]]>

when i launch the client webpage, everything is OK. when i checked my dvr sub-folder , i found that the "mergedVideo" created on the fms server but the video filesize is about 1K from start to end. why the mergedVideo file size doesn't change when the stream is still playing?

    This topic has been closed for replies.

    1 reply

    November 15, 2011

    You can't publish and play over the same netstream at the same time. Create two newstreams, publish over one and play over the other.