Problem with netstream and bytesTotal

I’m building a custom videoplayer and i have a problem with with the bytesTotal property of the netstream. I didn’t notice it when i was testing it locally (i’m guessing since the video is playing from the cache) but when i tested it online the bytesTotal was incrementing slowly instead of being available right away.

This breaks the player in more than one way.

Is there another way of finding the filesize, perhaps before the loading starts other than sending it via xml (which seems a bit clumsy)?

Right now my partially working code is (slightly edited) like this:

function timerHandler(event:TimerEvent):void {
    if (isLoading) {
        percentLoaded = (ns.bytesLoaded / ns.bytesTotal) * 100;
        if (percentLoaded == 100) {
            isLoading = false;
        }
    }
}

I will appreciate it if any of you can help me or at least point me in the right direction.

GD

Right of the top of my head, I think this might be due to no META data in the .flv file.
There are tools available on the internet to inject meta-data into the flv file.

Some .flv converters omit inserting meta data into the file, so flash player doesn’t know how big it is since it’s streaming the file. I’ve not run into the same problem you have, with the bytesTotal, but the video’s width and height can sometimes be missing from the meta data and you have to start playing the video before you can determine its dimensions.

[quote=flassari;2334407]Right of the top of my head, I think this might be due to no META data in the .flv file.
There are tools available on the internet to inject meta-data into the flv file.

Some .flv converters omit inserting meta data into the file, so flash player doesn’t know how big it is since it’s streaming the file. I’ve not run into the same problem you have, with the bytesTotal, but the video’s width and height can sometimes be missing from the meta data and you have to start playing the video before you can determine its dimensions.[/quote]

Thank for the input but the metadata is fine. I use it to get the size(in pixels that is) of the flv. If there was a “filesize” property of the metadata, that would be handy but there isn’t ( as far as i can tell).

It’s kind of ugly but… if you don’t find any solution maybe you could have a server side script that tells you the size of the file in advance. Assuming your flvs are in your server, and not somewhere else.

If you are loading the urls of the flvs in an xml, you could have the script that generates the xml look the size of the file, and then write it on the xml as an attribute.

<video href=“myvideo.flv” size=“17452093”/>

[quote=Pier25;2334422]It’s kind of ugly but… if you don’t find any solution maybe you could have a server side script that tells you the size of the file in advance. Assuming your flvs are in your server, and not somewhere else.

If you are loading the urls of the flvs in an xml, you could have the script that generates the xml look the size of the file, and then write it on the xml as an attribute.

<video href=“myvideo.flv” size=“17452093”/>[/quote]

Unless someone comes up with something more elegant i will probably do as you suggest or something like it.
Its probably just my poor coding skills but I’m wondering why it should be so difficult getting something as seemingly simple as the size of a file in AS3.