Skip to main content
Participant
August 18, 2009
Question

Issue with pre-recorded stream

  • August 18, 2009
  • 1 reply
  • 1198 views

I'm looking to have a stream generated by FMS Interactive 3.5 from a large number of pre-recorded .flv videos.  The videos need to start at a certain exact time, and need to play for an exact number of seconds.  (ie, a video needs to start at 3:00:00 and play until 3:00:15, with another video starting at 3:00:15)

Right now I'm reading the filename to play and its start time from a database, and telling the stream to play that file at the retrieved time, for a certain number of seconds.

app.myStream.play(app.nextVideo.filename,0,vLength,0);

If I leave vLength at the default, the currently played video IS replaced with the next video, but there's several seconds delay for some reason (the server will switch to the video at 3:00:15, but the client wont start seeing the video until 3:00:19), so I've been setting vLength to the number of seconds that the video is supposed to play.

With vLength set properly, the problem I'm having seems to be related to the reset parameter.  When set to 0, videos switch on time, but unless the client connects very shortly after the stream is started, the client's video will freeze at the end of the first video.  When set to 1, clients can connect at any time and begin watching the stream, but there's a buffering period at the beginning of each video, which throws the timing off.

I've been tearing my hair out over this, and can't seem to find a solution to get videos to start playing for the client at their exact scheduled times.  Any assistance would be greatly appreciated.

    This topic has been closed for replies.

    1 reply

    August 18, 2009

    The only way I've found to fix this is to clear out the buffer in response to a NetStream.Play.Complete code in the onPlayStatus event:

    my_ns.client = this;

    function onPlayStatus = function(info):void{

         if(info.code == 'NetStream.Play.Complete'){

              my_ns.bufferTime = 0;

              my_ns.bufferTime = 0.1;

         }

    }

    Once the 0.1 buffer fills up, I increase the buffer to my desired time.

    If anyone knows a better solution, I'd love to hear it, as I've never been very happy with this one.

    Participant
    August 18, 2009

    Sorry if I'm a bit slow, but exactly which issue did that clear up?  the video freezing up with reset is set to 0, or the buffering when reset is set to 1?  I'm still trying to get it to work in either scenario with little success. 

    I also just noticed, looking at the FMS server log, the client I have seems to be Connecting every 15 seconds (when a video is played by the server).  Is this a normal occurrance with streaming, or is there something wrong here?

    Participant
    August 18, 2009

    Okay, I've simplified this down to the absolute minimum I should need to play videos.  When a client connects to the stream, it will play to the end of the first video, and just freeze.  There's got to be something simple here that I'm doing wrong.

    Server-Side Code:

    application.allowDebug = true;

    application.onAppStart = function() {
    trace("Start Up");
    application.myStream = Stream.get("my_stream");

    application.myStream.play("scrubs",0,15);
    application.myStream.play("audrey",0,15);
    application.myStream.play("weezer",0,30);
    application.myStream.play("scrubs",0,15);


    }

    application.onConnect = function(clientObj){
    application.acceptConnection(clientObj);
    trace("Connected Client");
    }

    Client Code:

    var nc:NetConnection = new NetConnection();
    var ns:NetStream;

    nc.onStatus = function(info) {
    trace(info.code);
    if (info.code.indexOf("Success") != -1) {
      getStream();
    }
    }

    function getStream() {
    ns = new NetStream(nc);

    vid.attachVideo(ns);
    ns.setBufferTime(3);
    ns.play("my_stream",-1,-1);//,-1,-1,0);
    }

    nc.connect("rtmp://192.168.2.107/test/v1");