Skip to main content
Known Participant
April 18, 2010
Question

Sending information from server-side script to client

  • April 18, 2010
  • 1 reply
  • 618 views

I have created a script for an Adobe FMS application to broadcast a playlist of video files as a live stream. (internet tv)

I am now working on a custom Flash-based video player to play my stream.

My question is:
How do I send information from my server-side FMS application (main.asc) to the client-side video player? (e.g: title, duration of current video player)

I am new to AS, so please let me know if I need to provide more clarification.

    This topic has been closed for replies.

    1 reply

    April 18, 2010

    In Server side if you were calling a client side method by the name "testClientMethod" in this fashion :

    SERVER SIDE

    //where title and duration are variables containing the values to be sent to  client side. client is a object of Client class

    client.call ( "testClientMethod", null, title, duration ); 

    CLIENT SIDE AS3

    //nc is a NetConnection variable

    nc.client.testClientMethod = callMe;    

    function  callMe(parameter1:String, parameter2:Number):void {
         trace("Title:  "+parameter1);

         trace("Duration:  "+parameter2+" secs");
    }

    Hope this helps.

    thanks

    Mamata

    Janaki Lakshmikanthan
    Adobe Employee
    Adobe Employee
    April 19, 2010

    Hi,

    Like Mamata said you can use .call() method to call the client methods to send data. If you want to send the duration and someother stream related data, you can use onMetaData even handler. This will be called at the client side when ever the client plays a stream. You can retrive the duration, video/audio codecs, frame size etc. of the stream.

    var nc:NetConnection = new NetConnection();

    var ns:NetStream;
    var myClient:Object = new Object();

    nc.connect("rtmp://myserver/app");

    nc.addEventListener(NetStatusEvent.NET_STATUS, onNCStatusEvent);
    function onNCStatusEvent(infoObj:Object):void {
         trace(infoObj.info.code);
         if(infoObj.info.code == "NetConnection.Connect.Success"){
                   ns = new NetStream(nc);
                   ns.client = myClient;

                   myClient.onMetaData = metaDataHandler;
                   ns.play("mp4:myfile.mp4");
         }
    }

    function metaDataHandler(metaDataObj:Object):void {
         for(var p in metaDataObj){
           trace("metaDataObj."+p+":"+metaDataObj

    );

           //Here you get the metadata of the stream which is being played.
          } 

    }

    If you trying to send some other data to the client which is not found in the metaData then you will have follow what mamata had mentioned.

    Regards,

    Janaki L