This content has been marked as final. Show 3 replies
You can guess the duration:
var percent = _sound.getBytesLoaded()/_sound.getBytesTotal();
var duration = _sound.duration/percent;
However, this is still not quite accurate, because Flash continues to download even after getBytesLoaded is equal to getBytesTotal(strange!). So the only way to get the duration for sure is to use ID3 meta data.
Use the ID3 is something that i don't want. I use this code before and does'n work fine.
Is strange the Sound Class have this problem, i hope in the Flash 9 Adobe fix this problem. But, is impossible don't have a soluction for this problem.
> Use the ID3 is something that i don't want. I use this code before and does'n work fine.
I hear ya, I don't like using ID3 either. It should work, but you have to make sure your MP3s have ID3 v2 embedded, which in many cases you either don't have control over the MP3, or don't want to have to make sure they all have the tags.
I opted to use the approximation method I showed you. Additionally, I stored final duration in a SharedObject, so returning users would get the real duration immediately even if the song had been cleared from their cache.