4 Replies Latest reply on Jul 12, 2006 1:15 PM by Rothrock

    bytesLoaded/Total returns -1

    Kyle Type-S
      so I thought this would be simple enough, but i keep on getting a value of "-1" when i run this. the showVideo(mystream) function is called whenever a video is selected from a list component, and "mystream" is populated from an XML document. The video plays fine, so why am I getting a value of "-1"?

        • 1. Re: bytesLoaded/Total returns -1
          Kyle Type-S Level 1
          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?
          • 2. Re: bytesLoaded/Total returns -1
            Rothrock Level 5
            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.
            • 3. Re: bytesLoaded/Total returns -1
              Kyle Type-S Level 1
              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?
              • 4. Re: bytesLoaded/Total returns -1
                Rothrock Level 5
                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.