Skip to main content
Participant
April 3, 2007
Question

how to loop play a FLV file in FMS

  • April 3, 2007
  • 3 replies
  • 552 views
hello,everyone,i wanna fms play a recorded flv file again and again,but i don't know how to do it.
i try directly use "Stream.play",failed.
then i try PLAY again after i got the "NetStream.Play.Stop" status info code when the 1st time playing over.then its really can loop play now,however,the Stream object didn't clear up,since one new PLAY function called,new Stream created,and the old Stream object kept.over and over,they took lots of memory.
i just wanna FMS can loop play a single FLV file....
can anyone help me? thx very much.
    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    minzojianAuthor
    Participant
    April 3, 2007
    thx.
    what i mean is FMS play a FLV file and brocast as a defined stream name.check what am i do.
    application.onAppStart = function() {
    this.videofile = "test1";//one FLV file named test1.flv
    this.videoname="foo"
    this.newstream = Stream.get(this.videoname);
    if (this.newstream) {
    application.newstream.play(application.videofile, 0, -1);}
    }
    AS these codes,one flv file named test1.flv will be play and brocast as a stream named foo when the application start.however,this one can only play once.
    if i add a onStatus handler to call the play functionn again when the first time playing over.like this...

    application.newstream.onStatus = function(info) {
    trace(info.code);
    (info.code == "NetStream.Play.StreamNotFound") {//do nothing...
    }
    else if (info.code == "NetStream.Play.Stop") {//try to stop play the last stream...in order to clear the steam objct,but not work...
    if (application.newstream.play(false)) { application.newstream = null;
    }
    }
    else if (info.code == "NetStream.Unpublish.Success") {
    //when the last one unpublish success,publish a new one again.
    application.newstream = Stream.get(application.videoname);
    if (application.newstream) { application.newstream.play(application.videofile, 0, -1);
    }
    }
    };
    that's all.scripts r only for server side,don't care about the client side.
    i can loop play that flv file with these script,however,the stream object can't be clear up automaticly.u can check this situation in the fm2_console application.
    April 3, 2007
    var _nc:NetConnection = new NetConnection();
    _nc.connect("rtmp://localhost/test/test/");
    _nc.onStatus = function(_info) {
    trace("Level: "+_info.level+" Code: "+_info.code)
    if (_info.code == "NetConnection.Connect.Success")
    trace("connected to: "+this.uri);
    };

    var _ns:NetStream = new NetStream(_nc);
    _ns.connect(_nc);
    _ns.setBufferTime(5);
    video.attachVideo(_ns);
    _ns.play("test"); // no test.flv
    _ns.onPlayStatus = function(_info) {
    for(var prop in _info) {
    trace(prop+' '+_info[prop]);
    }
    if(_info.code =="NetStream.Play.Complete")
    _ns.play("test"); // no test.flv
    }



    Be CooL
    April 3, 2007
    It would be helpful if you post your code. There's no reason you shouldn't be able to replay a stream from it's onStatus event handler, so it's probably a syntax issue.