You want to optimize a user’s video playback by determining her network bandwidth.
Download an image file and time the download to calculate the speed of the user’s network connection.
Unfortunately, the Flash Player doesn’t have a built-in bandwidth detection system. And because actual bandwidth varies based on many factors (such as network usage, interference in wireless networks, applications running on the same system competing for bandwidth, etc.), there is no way to accurately predict what a user’s bandwidth will be for the next 10 minutes, hour, or any amount of time. However, you can measure a user’s actual bandwidth over a period of time and use that to determine what her bandwidth could be in the near future.
To measure a user’s bandwidth, you need to download a (noncompressed) file, such as a JPEG file using Flash Player. Using ActionScript, you can measure both the total bytes downloaded and the amount of time it took to download those bytes. Using those two values, you can calculate an average amount of data downloaded per unit of time. For the purposes of video, bandwidth is usually measured as bit rate in units of kilobits per second. There are 8 bits in a byte and 1,000 bytes per kilobyte. That means you can use the following to convert from bytes to kilobits:
kilobits = bytes / 1000 * 8;
The ratio of bytes/kilobytes and bits/kilobits is different if you are talking about data communication or disk storage. For disk ...