Skip to main content
June 6, 2008
Question

Please Help!!!

  • June 6, 2008
  • 5 replies
  • 655 views
Hello All,

I'm hoping someone will be able to help me out with a little problem I'm having. I have an FMS2 serving up a few movies. I have a hand-built flex application ( very simple flv player) that is able to connect to the FMS and pull all the movies over RTMP. I have that code running on HTTP server. I have Flash CS3, which I'm trying to use their components to build a very simple movie player. When I go through the wizard, and put the RTMP url into the properties of the player, it doesn't work. I'm not a developer, I'm a system administrator, so I'm not sure if I'm doing something wrong in CS3, but the Flex application can pull the movies fine.

Anyone have any debugging suggestions? I've checked the FMS2 logs and I don't see any errors or even connection attempts.

Thanks for the help,
Andrew
    This topic has been closed for replies.

    5 replies

    Participant
    October 22, 2008
    Perhaps components and Actionscript 3 only work with FVS 3?
    June 10, 2008
    For housekeeping sake...I made another post regarding this same issue, here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=578&threadid=1369303
    but will make further posts on this thread for consistency.
    June 10, 2008
    I have the same problem too, please supply your help
    Participant
    June 9, 2008
    I've been fighting the same problem, and I determined that the FLVPlayback component is waiting for the server to call the onBWDone() method in the ConnectClient class - this is to provide bandwidth detection, which FMS3 can be configured to do automatically. With FMS2, you'll have to write a routine to calculate bandwidth (I think there's an old tutorial on Adobe's site for FMS1 to do this), or just call the client's onBWDone() method with no params from your main.asc file. You could probably also work around it by overriding NCManager.connectOnStatus() to call the onConnected() method as well.

    Sorry for the lack of more detail but I haven't finished implementing a solution for this problem on my end yet.
    June 10, 2008
    Camerooni,

    Once you do finishing up your implementation, can you please provide a little more clarity in your findings? Are you telling me I will have to create a server side AS file, or just change the one inside my flash component?
    Participant
    June 10, 2008
    APeterson -

    Now that I have a working solution, I can provide some more clarity. I don't know for sure, but I think that the AS3 FLVPlayback component assumes it's talking to FMS 3 when you specify a RTMP url in the source property. I believe that FMS3 implements some methods that FMS2 does not to get the length of the video stream and to guess at the bandwidth that the client has. (I am only guessing because I am not familiar with FMS3)

    After digging through the FLVPlayback source code, I noticed that it will connect to FMS2 and the client will get the "NetStream.Connect.Success" event. However, the actual code that starts playing the video stream (NCManager.onConnected()) does not get called until the FMS server has had a chance to calculate the connection's bandwidth and then calls ConnectClient.onBWDone().

    In order to render the progress bar correctly, the FLVPlayback component also needs the length of the stream, which it obtains by calling getStreamLength on the server with the URL components after the host, app and instance names.

    So in order to make the AS3 flvplayback component work with FMS2, we need to write some custom server-side actionscript code to mimic the things that FMS3 does. I don't know whether this is a bug with the FLVPlayback component, but Adobe is sadly lacking documentation on this subtle gotcha. Perhaps I shall also log a bug via their JIRA system.

    Since there is no good way to attach code via this forum:

    here is a Pastie for the server-side actionscript that I wrote

    I've tested it on a local FMS2 installation and it works with the stock FLVPlayback component and an RTMP URL.

    And since Pasties are beautiful, but ephemeral, here is the sadly mangled code in the forum post body:

    application.onAppStart = function(){
    trace("Initialized. Listening on " + application.host + "/" + application.name);
    }

    application.onConnect = function(clientObj, userObject){
    //accept the client for now
    application.acceptConnection(clientObj);
    calculateBandwidth(clientObj);
    }

    /**
    * Called by the flvplayback client to get the duration of the stream
    */
    Client.prototype.getStreamLength = function(streamName) {
    return Stream.length(streamName);
    }

    /**
    * Calculate client bandwidth. Gratuitiously ripped off from Adobe sample app
    */
    function calculateBandwidth(clientObj) {
    clientObj.payload = "";
    for (var i=0; i<1024; i++) {
    clientObj.payload += "1"; //2K
    }

    var res = new Object();
    res.latency = 0;
    res.bwTime = 0;
    res.count = 0;
    res.sent = 0;
    res.client = clientObj;
    var stats = clientObj.getStats();
    res.beginningValues = {b_down:stats.bytes_out, b_up:stats.bytes_in, time:(new Date()).getTime()};
    res.onResult = function(p_val) {
    this.count++;
    var timePassed = ( (new Date()).getTime() - this.beginningValues.time );

    // If we have a hi-speed network with low latency send more to determine
    // better bandwidth numbers, send no more than 6 packetss
    if (( this.count >= 4 && this.count < 6)&&(timePassed < 2000)) {
    this.sent++;
    this.client.payload += this.client.payload;
    this.client.call("onBWCheck", this, this.client.payload);
    }
    else if ( this.sent == this.count ) {
    delete this.client.payload;
    // Got back responses for all the packets compute the bandwidth.
    var stats = this.client.getStats();
    var deltaDown = (stats.bytes_out - this.beginningValues.b_down)*8/1024;
    var deltaTime = ((new Date()).getTime() - this.beginningValues.time)/1000;
    var kbitDown = Math.round(deltaDown/deltaTime);
    this.client.call("onBWDone", null, kbitDown );
    }
    }

    // First payload is empty to check latency
    res.sent++;
    clientObj.call("onBWCheck", res, "");
    for ( var k = 0; k < 3; k++ ) {
    res.sent++;
    clientObj.call("onBWCheck", res, clientObj.payload);
    clientObj.payload += clientObj.payload;
    }
    }

    p.s. - DamonDamon -- your issue is different - you need to make sure that the object you assign to the NetStream.client property has an onMetaData(infoObject:Object):void method. I'm sure that you can find some good examples via Google of a search of the flash player forums.
    June 9, 2008
    I'm having similar problems. I'm a Streaming Service subscriber (Playstream) and I'm trying to utilize Actionscript 3 video playback components with the service's RTMP, but its not working. I've received a positive: "NetConnection.Connect.Success," but that is it. The movie is not playing otherwise. Here's my code:

    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://fvss.playstream.com/fvssod/escstream/Damon_FLV_test/");

    var ns:NetStream = new NetStream(nc);

    nc.onStatus = function(ncObj:Object) {
    trace(ncObj.code);
    if (ncObj.code == "NetConnection.Connect.Success") {
    ns.setBufferTime(1);
    myVideo.attachVideo(ns);
    ns.play("flv:creature_comforts");
    }
    };

    (sorry to Forum Admin, I'd use the specified "Attach Code", but I don't see it anywhere?)

    June 9, 2008
    very strange, but I'm able to stream the video with previously mentioned code example, but its very sporadic. It seems like every 5-10 loads (refresh) works? Very random.
    I used the example files from this tutorial and just pasted my RTMP file in:
    http://www.adobe.com/devnet/flashmediaserver/articles/beginner_as3_fm3.html

    I'm wondering if I'm not handling all the metadata correctly or some related event, but then again I'm not sure if I know what data is being passed back from my video service? I called and asked what version of Flash Streaming Server they're using and its: FVS 2.5.4 This may have somthing to do with it. Perhaps components and Actionscript 3 only work with FVS 3?