While working on a custom video player project today I noticed a strange anomoly with the bytesTotal value returned by a NetStream object loading data from a local cache.
The first time you play a remote FLV via NetStream the bytesTotal result is correct, it’s the size of the file as sent by the server. However once the FLV is in the users local cache, and the SWF was reloaded, the bytesTotal value was reporting a size of 4 GB exactly until the stream had “settled down”, and then it returned the correct value. This seemed to take a second or so at most, but it still meant that my code needed changing to cope with it.
After making the connection I was storing the bytesTotal value in a uint. An event based check was comparing this uint with the bytesLoaded value waiting for them to equal each other (i.e. get to 100% downloaded). Of course this would never happen, because it was waiting for 4GB worth of data to download.
So rather than assigning the value to a variable I’m now simply comparing bytesTotal directly with bytesLoaded and then setting a Boolean if they match (downloadComplete = true) to avoid future comparisons.
Even so, it was an interesting oddity I thought worth reminding myself of in the future. Hence this blog entry
Make yourself heard
All about Photon Storm and our
HTML5 game development services
Filter our Content
- Cool Links
- Flash Game Dev Tips
- Game Development
- Geek Shopping
- In the Media
- Phaser 3