This content has been marked as final. Show 4 replies
update: so it seems that i'm getting the -1 and 0 values because the metadata has not finished loading. If you try to check once the video starts playing, then it gives the correct values.
So my question now is how do you get it to call only after the metadata has finished loading? I was under the impression that .onMetaData did just that, but aparently not?
I don't think bytesLoaded and bytesTotal are part of the meta data. So the two things are separate issues.
onMetaData happens once, whereas the bytesLoaded property would obviously change over time and will need to be read many times. And evidently bytesTotal changes as well.
The main answer is you get -1 because that is the answer you get. Not so helpful, but really it is the answer. This same problem has stumbled people making preloaders for loadMovie for many years as well.
Since the bytesLoaded and bytesTotal will sometimes read 0, sometimes read -1, and eventually get to their correct values, you have to add something that basically checks to make sure they are greater than 0 before you try and rely on them.
I guess the big question is, "What are you trying to do?" Since you are using the NetStream class, you should probably look at onStatus and use that to tell when things are buffering, etc. Otherwise I'm not quite sure why you would be looking at bytesLoaded.
yeah, i came to the same conclusion after i got the bytesTotal to work eventually , that is -1 is the default value untill otherwise calculated.
I want to know because i want an event to happen when each file gets done downloading, while it's streaming the FLV. what would the "onStatus" function for that be? or would you set up a listener to watch for it?
AFAIK there isn't an NetStream event for complete file download. Which makes sense for something streaming – kinda if you think about it, maybe.
Check the help files for NetStream.onStatus, you will find it is mostly concerned with issues around the buffer and playback status. Lots of good stuff in there, but nothing for your particular purpose.
If you are trying to build you own player and want to give the indications of how much is downloaded, then it looks like you will have to make your own preloader code using onEnterFrame of setInterval.