views:

242

answers:

1

I've been trying to lick this problem for months now... In Flash 9 I'm trying to load a streaming MP3 file and calculate its track length. I can do that fine, But when the mp3's channel is mono, the time is double that of the original track length. How did I figure this out? Well, I tested my player by recording into Sound Recorder on Windows, but, luckily, I forgot to record the MP3 in Stereo.

Now, in Flash, I've tried calculating the duration many ways using bytes loaded, bytes total, the play position and all of the formulas you might think of using. The math is fine. The issue is that when Flash loads an mp3, it automatically assumes that the file is in stereo. So, when it loads the data, it goes ahead and doubles the amount of bytes it thinks it has because it recognizes one channel at a certain size, and then just doubles it for stereo. This produces a false value of the load size which still, with the correct math, doubles the track length. That's why mono doesn't work with the usual formula we use.

To combat this, I need a way to determine whether the file is mono or stereo. And no, ID3 data returns the wrong value too, I've already tried determining manually using soundTransform.leftToLeft, soundTransform.leftToRight, soundTransform.rightToLeft, and soundTransform.rightToRight (it returns values for stereo sound).

I don't know of any way to have Flash tell you what audio channels the file has, correctly. I hope I'm just overlooking something and any help or troubleshooting tips, whether or not I've already tried it, will be greatly appreciated.

A: 

Are you sure the ID3 is correct?
I've had several mp3's that report the wrong length, not because of stereo/mono issues but because of corrupt headers.

grapefrukt
For regularly recorded mp3s the tags are correct, but since this one was created with Sound Recorder, there is no ID3 tag. So yeah, it skips that condition statement. I should've said that.