Hey guys and gals,
Im currently coding an MP3 player for a project, i want to output a time display.
Currently i am waiting for the Event.COMPLETE in order to get the tracks length using
mySoundObj.length
but this means that whilst the MP3 is loading i do not have any length data to display.
I was wondering if there was a way to access tracks total length during the loading process?
Thanks!
-CA
Hmmm, halfway there…
Kind of an estimated length.
//get Estimated length based on the bytes loaded and bytes total var estMill:Number = (mySound.bytesTotal / (mySound.bytesLoaded / mySound.length)); var estMin:uint = Math.floor(estMill/60000); var estSec:uint = (estMill%60000); var estSecTen:uint = Math.floor(estSec/10000); estSec = Math.ceil(estSec%10000)/1000; var estLength:String = (estMin + ":" + estSecTen + "" + estSec).toString(); trace(estLength);
Still keen to hear if anyone knows a way of accessing the true length during the load process

- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
I’ve banged my head against the wall on this many times and have come to the following conclusion:
It will never be 100% accurate until the mp3 has loaded completely so you just have to keep updating the text field using a calculation like above with an ENTER _FRAME until the mp3 has loaded completely.
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 6-7 years
- Interviewed on the Envato Notes blog
- Item was Featured
- Microlancer Beta Tester
- Referred between 200 and 499 users
Hmmm, halfway there…Kind of an estimated length.
//get Estimated length based on the bytes loaded and bytes total var estMill:Number = (mySound.bytesTotal / (mySound.bytesLoaded / mySound.length)); var estMin:uint = Math.floor(estMill/60000); var estSec:uint = (estMill%60000); var estSecTen:uint = Math.floor(estSec/10000); estSec = Math.ceil(estSec%10000)/1000; var estLength:String = (estMin + ":" + estSecTen + "" + estSec).toString(); trace(estLength);Still keen to hear if anyone knows a way of accessing the true length during the load process
![]()
no, there is no way to access the total length of the file so you always calculate the length of the downloaded portion.
no, there is no way to access the total length of the file so you always calculate the length of the downloaded portion.
That is so lame. Not the workaround but that there is no way of telling the length before it is loaded. Other thing is that you can’t tell when the sound actually starts, I had to come up with a workaround for that (isBuffering check was a fail).
no, there is no way to access the total length of the file so you always calculate the length of the downloaded portion.That is so lame. Not the workaround but that there is no way of telling the length before it is loaded. Other thing is that you can’t tell when the sound actually starts, I had to come up with a workaround for that (isBuffering check was a fail).
My workaround for that was to check the channel.position, if greater than 0 then sound has started 
Also, thanks to everyone for your advise, a shame that there is no way to get the length. I may use an XML variable for the length and use that during load and when Event.COMPLETE is called then use the actual .length property.
Thanks guys!
PS: if anyone wishes to use the code i posted, feel free 
Yeah ,seems estimating length is the only way
My workaround for that was to check the channel.position, if greater than 0 then sound has started![]()
I also came up with that exact solution 
Back on topic: Flash could read the value that PHP got about the mp3:
With this PHP script it’s possible: http://getid3.org/. You can add that to the xml:
My workaround for that was to check the channel.position, if greater than 0 then sound has startedI also came up with that exact solution![]()
![]()
Great minds… 
Great minds…![]()
Check out my PHP solution. Tell me if you need help.
