If you're not dealing with a live stream, you generally have to check for the
Netstream.Play.Stop *and* Netstream.Buffer.Empty events. Simply checking for
the Netstream.Play.Stop can give unwanted results, especially if you set a
large buffer value for streams - if you set the buffer to 5 seconds, for
instance, the Stop event will fire 5 seconds before the stream ends, because
that's how much time is set in the buffer.
You can use a boolean to determine whether the Buffer.Empty is fired because
the end is reached, or if it's just plain buffering. Something like:
ns.onStatus = function (info) {
if (info.code == "Netstream.Play.Stop") {
this.stopped = true;
} else if (info.code == "Netstream.Buffer.Empty") {
if (this.stopped) {
// do something here, stream has reached end
} else {
// stream is buffering
}
} else if ("Netstream.Buffer.Full") {
// playing
}
}
-Mark
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Duncan
Reid
Sent: Wednesday, November 16, 2005 1:05 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] End of flv playback event
Agreed, I have only seen the NetStream.Play.Stop fire at the end of an FLV.
I recall reading, i think here, that this wasn't always the case but i could
never find another time it fired other than at the end of an FLV... It seems
as though when the video needs to buffer and catch up it will stop but only
an "Empty" code gets sent, if you pause the flv manually it doesn't seem to
send a "Play.Stop" message.
So I've been using the Play.Stop to tell me when the video is done and
haven't had any problems with it. I would be interested to know if that's
not proper though.
A rough breakdown of the onStatus handler could be something like:
ns.onStatus = Delegate.create(this,function(info:Object) {
if (info.code == "NetStream.Play.Stop"){
//playback has stopped or what i think is the end of the movie
}
else if (info.code == "NetStream.Buffer.Empty"){
/* Data is not being received quickly enough to fill the buffer. Data flow
will be interrupted until the buffer refills,
at which time a NetStream.Buffer.Full message will be sent and the stream
will begin playing again. */
}
else if (info.code == "NetStream.Buffer.Full"){
//The buffer is full and the stream will begin playing.
}
else if (info.code == "NetStream.Play.Start"){
//Playback has started
}
else if (info.code == "NetStream.Play.StreamNotFound"){
//The FLV passed to the play() method can't be found, show error
}
}
);
Dunc
On 11/16/05, Jordan L. Chilcott <[EMAIL PROTECTED]>
wrote:
>
> Why not add a listener object to the onStatus event of your
> NetStream. It will inform you when the playback has stopped. You can
> take action from there.
>
> jord
>
> On Nov 16, 2005, at 10:39 AM, Marlon Harrison wrote:
>
> > Is there any special trick to accurately getting an end of flv
> > playback event?
>
> --
> Jordan L. Chilcott, President
> Interactivity Unlimited
> Guelph, Ontario
> ---------------------------------
> Tel: (519) 837-1879
> eFax: (253) 276-8631
>
> mailto:[EMAIL PROTECTED]
> http://www.interactivityunlimited.com
> iChat/AIM: j1chilcott
>
> Author: "Building Web Sites with Macromedia Studio MX"
> Author: "Building Dynamic Web Sites with Macromedia Studio MX"
> Author: "Flash Professional 8: Training From the Source"
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders