0
votes

I have an application, built using Actionscript 3, that plays mp3 files. AS3 sometimes reports the length of the file incorrectly. I asked a question about this a couple of weeks ago and got a link to:

http://www.kirupa.com/forum/showthread.php?332063-Incorrect-sound-length-property-value

I am including the correct length in an XML file, and thought it would be fairly easy to get AS3 to play the file correctly using that value. Unfortunately the file stops playing at the length AS3 thinks is the right value rather than the real length.

Is there a solution?

3
I'd say repack your mp3s, in order to make AS3 correctly dteremine their length.Vesper
This program will be used for many mp3 files from many sources. There is no way I could repack them.TomJeffries
I hope that this isn't a dumb question, but have you read this: stackoverflow.com/questions/669974/…Craig
I'm waiting until loading is complete to get the length.TomJeffries

3 Answers

0
votes

A few things you could try:

-Check the events your using. Use Event.complete to make sure your sound is fully loaded before you get the length.

OR

-Try using a timer and set it to the length you gave in the XML file.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html#Timer%28%29

  • It depends on what your doing, but there is a possible problem of audio stopping or looping if the window goes out of focus. Try keeping the window in focus and see if that is your problem. if it is, you may need to use event.activate and event.deactivate to pause the audio.

http://www.emanueleferonato.com/2011/03/29/pausing-a-flash-game-or-movie-detecting-its-focus/

0
votes

Sort of an answer, not one I like, but maybe this is what we need to do:

Decided to load the song into Blaze Audio's RipEditBurn Plus and do a reconversion, just to see what happens. With the cursor over the file name, the correct length comes up before I load it. Amazing- why does AS3 get it wrong?

The new file works and AS3 reads the correct length. There seems to be something wrong with the original file. The file size on both files is exactly the same.

If I don't get a better answer in the next day or so I'll mark this as the correct one, but it would be nice to have a better way to do this.

Edit- YIKES!!!!! I had renamed the song before running it with the app. Everything works fine. So I just changed the name back- and it comes out the wrong length!!!????? Long ago I worked with mp3 file formatting, but I don't remember anything in the header that would cause this problem. And the name of the song is Ayize- it's a South African song. If I just make it ayize it works.

Very, very strange.

0
votes

I found the real answer, and it's pretty crazy. I had set the project aside while I did some other things, got back to it a couple of days ago. I had a different set of songs, some of which I needed to edit. I tried the edited versions, and AS3 played the non-edited version! I realized that because I am streaming these from a host, AS3 seems to keep a copy someplace on my computer of the original.

If I had run it on a different computer I would have known immediately, but at least I finally did find out what was going on.