Skip to main content
Participant
June 21, 2006
Question

End of streaming file

  • June 21, 2006
  • 1 reply
  • 245 views
Hello,

I've two problems with the streaming from a flv-file from a FMS2.

First, when I stop the stream (pause) and want to restart it i have a small jump in the stream.

Second, how can I detecting the end of the stream/file?

Here is my code:
import mx.controls.*;

var stream_wnd:Video;
var stream:String="water"; //File
var fms:String="rtmp://192.168.1.1/Video_1/video"; //FMS2
var telegramm_btn:Button;
var play_btn:Button;
var status_stream:Boolean=false;
var endTime:Number;

var nc:NetConnection = new NetConnection();

stop();

nc.connect(fms);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(2);
this.stream_wnd.attachVideo(ns);
this.play_btn.onRelease = function(){
if (status_stream){
ns.pause();
}
else {
play_btn._visible = false;
ns.play(stream);
status_stream=true;
}
};


this.pause_btn.onRelease = function(){
ns.pause();
};

this.back_btn.onRelease = function(){
ns.seek(1);
};
    This topic has been closed for replies.

    1 reply

    Participant
    December 8, 2009

    Hello ssve,

    I've experimented with this a lot and found that the only accurate way is to listen to the net status event and check for when you get the Buffer Empty status and Play Stop status side by side:

    protected function handleNetStatus(event:NetStatusEvent):void

    {

        if (lastNetStatusCode == "NetStream.Buffer.Empty" &&

            event.info.code == "NetStream.Play.Stop" ||

            lastNetStatusCode == "NetStream.Play.Stop" &&

            event.info.code == "NetStream.Buffer.Empty")

        {
            // at end!
        }
    }

    As you can see by my if statement, they don't always come in the same order. But they are always adjacent.

    But before someone yells at me, I must note that this is the only way for generic videos. When using FMS I believe there are other, better ways to do it. But I haven't used FMS yet, so someone else will have to explain that.

    Thanks,

    Philip