Bug with Sound channel position and mp3s less than 128kbps
Man I just keep finding more and more bugs with Sound. This one is actually really bad because it has no workaround, unlike the others.
If you have an mp3 file that is less than 128kbps and you get its channel.position at a particular point in time and try to play from that position it jumps ahead in the file. The amount it jumps ahead is based on how far away it is from 128kbps (a 56kbps file will jump more than a 64kbps one).
But wait, it gets worse. Much worse.
Even though it has jumped ahead in the track, the channel.position returns where it's supposed to be, not where it actually is! That's right, Flash is confused and reports to you that the mp3 is somewhere earlier in the file, not where it actually is playing from!
channel.position reports its position but it's actually playing somewhere many seconds ahead (I've seen it more than 30 seconds to many minutes depending on the length of the file), getting worse and worse over time. I'm tracing the position in a TextField in an ENTER_FRAME listener and it's way off from what's playing.
Wow. I mean, just, wow. 128kbps and up works just fine. Anything less and you're screwed.
I've discovered so many bugs in the Sound class in the last 12 hours, it's kind of disheartening. I'm losing faith in the Flash player team and in Adobe for letting this kind of stuff get through QA.
Posted in Actionscript, Bugs, Flash
August 8th, 2008 at 12:30 pm
i ran into this one a few months ago. if you search adobe's bug database, this is on there.
sucked for us since we were using low quality MP3s for a bandwidth sensitive app – we just left the bug there and hoped people wouldn't notice.
August 9th, 2008 at 8:31 am
What about > 128kbps?
August 10th, 2008 at 11:48 pm
It's probably variable bitrate. Try using CBR with lower bitrates.
August 11th, 2008 at 4:53 am
I know better than to use a VBR.
By now, I would hope that the Flash community knows the Flash player does not get along well with VBRs. That's a different issue than this, and one that Macromedia/Adobe has never addressed.
August 14th, 2008 at 12:46 pm
Thanks for posting this. I'm just learning AS3, and just discovered this this morning – well, I discovered that it wasn't working as advertised, but I never would have figured this out – so, thanks. Even after matt (above) said this was already in Adobe's bug database, I had trouble finding it – I guess known issues don't make it into the "Knowledge Base" until there is a known fix or work-around.
Anyway, here is an additional detail – maybe it will make more sense to you as to why this should be: during my testing I discovered that if I imported the audio file into the library first – i.e. at author time – instead of loading the sound from an external file at run time, that my play/pause buttons now worked fine!
August 14th, 2008 at 2:06 pm
THANK YOU! I have wasted the better part of my day trying to figure out why two mp3s were messing up in my player.
IMPORTANT! In addition to the 128kbps, the mp3 file must be sampled @ 44.100kHz. Anything higher messes it up as well.
Cheers!
Heather
August 22nd, 2008 at 12:32 pm
Very helpful.
I had 32kbps clips and was struggling to find out why pause was not working. Incedentally – if you hardcode the Sound.play(startposition) start position to something like 5 seconds… and your song is a minute (60 seconds)… it will resume playing at 5 seconds and will stop at 55 seconds… 5 seconds from the end. In other words it ill come up startseconds short. This has something to do with the bug I'm sure.
Lastly – somewhat related is that if you're trying to get ID3 tags Event.ID3 to fire… make sure your mp3 files have id3v1.1, or id3v2.3 or better. iTunes had my tags at 2.2 and they were not recognized by AS3.
Hope this helps.
Paul
September 17th, 2008 at 12:35 pm
I ran into this major bug a while ago. If I remember well, related to the sample rate, and the position you get is something like:
position * {sample_rate}/ 44100.
October 6th, 2008 at 5:42 am
Thanks Steven. I'm also amazed that Adobe let this one get by. When flash is being used to power 95% of the media players on the web, you can't punt on this kind of thing up.
October 6th, 2008 at 6:24 am
FYI — I just installed the beta (RC) for FlashPlayer 10 and this bug appears to be fixed! All of my clips — no matter what the bitrate — pause/play and scrub perfectly…
December 7th, 2008 at 3:50 pm
I know I'm late to the post-a-comment party, but thank you so much Steven (and Heather) for your information on this. I was seriously ready to put my head through a wall over this one. Sounds like it's time to pony up for cs4.
April 27th, 2009 at 12:43 am
This bug remains in flash player10 for IE, but in FireFox it works fine.
June 17th, 2009 at 7:56 am
I found this site because I have been aware of this issue for years, and was curious if anyone had a work-around. Not looking good so far, but this is good to know.
This is only one of the millions of issues Flash has. I hate coding for it… if I have to make another flash game, I'm jumping out the window.