View comments | RSS feed

NetStream.onStatus

Availability

Flash Player 7.

Note: This handler is also supported in Flash Player 6 when used with Flash Communication Server. For more information, see the Flash Communication Server documentation.

Usage

my_ns.onStatus = function(infoObject:Object) : Void{
   // Your code here
}

Parameters

infoObject A parameter defined according to the status or error message. For more information about this parameter, see "Description," below.

Returns

Nothing.

Description

Event handler; invoked every time a status change or error is posted for the NetStream object. If you want to respond to this event handler, you must create a function to process the information object.

The information object has a code property containing a string that describes the result of the onStatus handler, and a level property containing a string that is either status or error.

In addition to this onStatus handler, Flash also provides a "super" function called System.onStatus. If onStatus is invoked for a particular object and there is no function assigned to respond to it, Flash processes a function assigned to System.onStatus if it exists.

The following events notify you when certain NetStream activities occur.

Code property Level property Meaning
NetStream.Buffer.Empty

status

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.

NetStream.Buffer.Full

status

The buffer is full and the stream will begin playing.

NetStream.Play.Start

status

Playback has started.

NetStream.Play.Stop

status

Playback has stopped.

NetStream.Play.StreamNotFound

error

The FLV passed to the play() method can't be found.

If you consistently see errors regarding buffer, you should try changing the buffer using the NetStream.setBufferTime() method.

Example

The following example displays data about the stream in the Output panel:

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");

stream_ns.onStatus = function(infoObject:Object) {
   trace("NetStream.onStatus called: ("+getTimer()+" ms)");
   for (var prop in infoObject) {
      trace("\t"+prop+":\t"+infoObject[prop]);
   }
   trace("");
};

See also

System.onStatus, NetStream.setBufferTime()

Comments


recoveredfromflashMX2004 said on Aug 4, 2004 at 3:42 PM :
shahaf said on Jan 24, 2004 at 11:42 PM :

Regarding "NetStream.Buffer.Empty"
I'm stuck with this problem and your documentation is very poor. I understand that not enough data is received but how do I fix it? What can I do to prevent it from happened? Why is this problem is not consistent?

Please add more information regarding this very serious problem. I cant use the application I wrote because of it, and all the documentation I found all over the web is this one sentence.

Please reply... shahaf@unisfair.com

Regards Shahaf


rampage733 said on Mar 3, 2004 at 10:46 AM :

I am kind of new with the Netstream thing but it seems like buffer.empty will be that you don't have anything in the buffer or you may be setting the buffer to high. I would check it off of a local server as opposed to a remote server and see if your problem still exists


jepo said on Apr 1, 2004 at 1:49 PM :

You might find help in referring to the NetStream.setBufferTime() method entry.
The docs have been updated to inclue information about these issues, and will be available after the next Help update.


spaz101 said on Apr 16, 2004 at 3:14 PM :

Why is there no documentation for all values through the NetStream.onStatus method? The Code Property list as shown in this documention is shy of "NetStream.Play.PublishNotify " and "NetStream.Play.UnpublishNotify", and perhaps others not documented. I would have liked all available values to know what a stream can do when a change occurs.


garygearhead said on Jun 22, 2004 at 8:10 AM :

I appreciated seeing a Macromedia Employee respond to this thread. Jepo, thanks. But the NetStream.setBufferTime() description is vague too. Why is it too much to ask that Macromedia provides clear and thorough documentation of its programming languages. I can't find any documentation on .code or .level - here's some sample code in the help file.

netStream.onStatus = function(infoObject) {
status.text += "Status (NetStream)" + newline;
status.text += "Level: "+infoObject.level + newline;
status.text += "Code: "+infoObject.code + newline;
};

What are the possible values of each of these three returns and are there other properties of the status we can check on?


No screen name said on Aug 3, 2004 at 7:16 PM :

I'm using the sample code above to see what netstream.onStatus is
returning when I play my video, but I don't understand why I never see
NetSteam.Play.Stop....
FredzCode said on Aug 20, 2004 at 1:59 PM :
NetStream.Data.Start

is a undocumented code ... dont think its precious but does exist.!
Squee-D said on Sep 1, 2004 at 3:48 PM :
Here is a crosspost from flashcoders mailing list. I would love this issue to be sorted. It regards onStatus when using a progressive download of an FLV.

My problem:
Using netstream and netconnection with ns.play("some.flv") in MX 2004 pro - Netstream.Buffer.Empty is not firing when it is supposed to.

The compression methods I have tried (and the pros/cons):

Flash Video Exporter 1.2 to FLV
Pro - Decent quality and compression
Con - Netstream.Buffer.Empty does not fire when the video is forced to pause

Sorensen Squeeze 4 (trial) to FLV
Pro - Excellent quality and compression
Con - Netstream.Buffer.Empty does not fire when the video is forced to pause

Flash MX 2004 Pro to FLV
Pro - Decent quality and compression - similar to Flash video exporter 1.2 Con - Netstream.Buffer.Empty does not fire when the video is forced to pause

Flash Video Exporter 1.0 to FLV
Pro - Netstream.Buffer.Empty fires as expected
Con - Abysmal, almost unusable quality and compression.

Is there a work-around to find out when the stream is buffering and paused? Is there a trick to making sorenson provide the Buffer.Empty status. I am assuming it’s the duty of the exporter to provide sufficient information for this to work as 1.0 works and 1.2 does not. I believe MM have acknowleged the bug in 1.2 and have suggested to others to use 1.0 - I am not willing to make that compromise because 1.0 creates significanlty lower quality, larger files.
robant_robz said on Oct 7, 2004 at 11:44 AM :
I, too, am not seeing the NetStream.Play.Stop code show up when a I do a trace. I have some code that relies on this being passed so that, once the video stops playing, it will move on to another frame. Any ideas?
kjasonwest said on Oct 28, 2004 at 12:37 PM :
I have three short videos that I've created a player for. I am using the netStream.Play.Stop event to reset the video back to the first frame and re-enable the play button. One of the videos responds to the event, but the other two do not. I have used a trace statement and found that the event is not even boadcast when the two faulty videos stop playing.
What could be the cause of that?
kjasonwest said on Oct 28, 2004 at 12:56 PM :
Okay, I got it to work for me!
I am using Sorenson Squeeze 4.0.
I created my own in / out points and "squeezed" the video again and it worked. I figured that by creating my own out point, it would force the software to insert the tag that triggered the netStream.Play.Stop event, and it did!!!
Hope that helps you. I've seen your posts on several forum sites ... I've been looking for a solution too.
henry_ilabs said on Dec 11, 2004 at 11:27 AM :
i guess thats ok for people who have squeeze - any suggestions for
those without? I can't belive that this is the only place online where
this seems to be being discussed :-)

-h
DigitalGroover said on Dec 17, 2004 at 9:14 AM :
NetStream.Buffer is not really useful, neither are the MM Mediacomponents. I normally use NetStream.bytesLoaded / bytesTotal (even dynamic streams) to estimate bandwidth and create my own buffer... it works perfect.
kevin_murray said on Dec 31, 2004 at 11:26 AM :
kjasonwest said on Oct 28, 2004 at 12:56 PM :
"Okay, I got it to work for me!
I am using Sorenson Squeeze 4.0."

Could you be more specific about how you created your own in/out
points? I'd like to try this myself.
james_b said on Jan 1, 2005 at 12:28 PM :
I don't have Sorenson but was able to get the onStatus event
"NetStream.Play.Stop" and "Netstream.Buffer.Empty" to work for
progressive downloads by taking a cue from kjasonwest and using the
editing functionality in MX2004 itself to add in/out points to my clips
(.mov/.avi) as follows:

1) File > Import > Import to library
2) Video Import Wizard: Choose to Embed the video
3) Choose "Edit the video first"
4) Use the arrows to the left and right to set in/out points
5) Click "Create Clip", name the clip and complete the wizard

If you're using progressive downloads:
6) In Library, right click and choose "properties" for the clip you just made
7) Click "Export" and save as Flash Video.
8) Delete the clip from your library

The exported clip triggers the "Play.Stop" and "Buffer.Empty" correctly.
No screen name said on Jan 13, 2005 at 5:43 PM :
Any ideas how to determine the end of an FLV via
NetStream.Buffer.Empty? The FLV is loading into a video object.

I'm trying something to the effect of:

my_stream.onStatus = function(infoObject:Object) {
 if (infoObject:Object == "NetStream.Buffer.Empty") {
   _root.gotoAndPlay("Done");
 }
};
nintendo-n8dawg said on Jan 13, 2005 at 6:17 PM :
i got the script to go through without errors but; it didn't go to the frame
label when the FLV finished playing

i'm trying to invoke an action when a FLV is done playing. Any help is
appreciated. Here's the code I'm trying:

my_video.onStatus = function(infoObject:Object) {
if (infoObject.code == "NetStream.Buffer.Empty") {
_root.gotoAndPlay("Done");
}
};
Flash-Ripper.com said on Jan 24, 2005 at 8:58 AM :
Also, why onMetadata event still not documented? However it is accessible via ActionScript; the sample code:

nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.onMetaData = function(obj) {
txtDuration.text="Total TIme: "+obj.duration;
trace("Duration is: "+obj.duration);
trace("VideoRate is:"+obj.videodatarate);
trace("AudioRate is:"+obj.audiodatarate);
};
mcVideo.attachVideo(ns);

So isn't i good to include onMetadata event in future Flash/Flash Help Update/Version?
petetschudy said on Jan 25, 2005 at 7:20 AM :
Is there any documentation to describe how to create a loading animation for the buffer?
cheegs said on Jan 26, 2005 at 12:50 PM :
I've used the workaround posted above by james_b in the past and it
does trigger NetStream.Play.Stop. But as I recall when I used the same
FLV with the MediaPlayback component, the playhead "sticks" to the
right of the slider and can not be scrubbed through the video (as if the
FLV's duration was not passed to the component in order for it to function
properly). Downloaded a trial of Sorensen Squeeze 4 and it created a
file that would function properly under both situations.
obspaceman said on Mar 10, 2005 at 6:38 PM :
Ok how do you tell the end of a file when it is streaming? From what I can tell the bufferTime set actually causes a Stop at duration - bufferTime so its not an accurate measure of the end. Bytes loaded versus total bytes would be good assuming this works over rtmp.
obspaceman said on Mar 10, 2005 at 6:41 PM :
The other question I have is why can't I get the duration of an mp3 file when using FCS and rtmp unless I write server side code and use a shared object?
dodgetigger said on Jun 9, 2005 at 2:07 AM :
I am trying to make a player that streams video from a flash communication server, and if the bandwidth of the client is not high enough, a low bandwidth video is automatically selected and starts playing.

I tried to do this by selecting the low bandwidth video when the buffer runs empty, so I have code similar to this:

this.netStream.owner = this;
this.netStream.onStatus = function(infoObject) {
if (infoObject.code == "NetStream.Buffer.Empty"){
this.owner.changeToAudio();
}
}

But I also have the problem that NetStream.Buffer.Empty is never called.
If I do a onEnterFrame function which writes the netStream.bufferLength into a textfield, I can see it never gets 0, only something like 0.16...

It seems like the "NetStream.Buffer.Empty" event is not triggered consistently. Is this a bug or am I doing something wrong?
Does it matter what value is set for bufferTime? I am using 3 seconds, but also tried other values around that.
fuad_all said on Jul 1, 2005 at 4:26 AM :
i got the same problem but not with every flv video file.
NetStream.Buffer.Empty works with some flv files , not every !
and the bufferLength value stays at 0.143 and NetStream.Buffer.Empty event won't triggered.

It work's when using custom point with Sorenson but i have many .wmv video files that need to convert to flv (batch).

There is no **** explanation from macromedia side.
That's makes me crazy.
fuad_all said on Jul 1, 2005 at 8:24 AM :
i think it's Sorenson Squeeze problem even on version 4.1
it sets false duration meta parameter to flv files.

After converting with Riva Encoder the problem is off.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001596.html