Bug with Sound channel position and mp3s less than 128kbps

August 7th, 2008 by Steven Sacks

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

13 Responses

  1. matt

    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.

  2. Jason Fistner

    What about > 128kbps?

  3. maliboo

    It's probably variable bitrate. Try using CBR with lower bitrates.

  4. Steven Sacks

    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.

  5. Bob

    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!

  6. heather

    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

  7. Paulfm

    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

  8. Simon

    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.

  9. brian

    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.

  10. brian

    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…

  11. fubbs

    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.

  12. Neo

    This bug remains in flash player10 for IE, but in FireFox it works fine.

  13. Z

    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.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Steven Sacks

I am a professional Flash developer with over 13 years of programming experience. I have consulted for high-profile agencies and companies in San Francisco, Los Angeles, Atlanta and New York, and developed numerous award-winning websites and rich internet applications for clients including Adobe, Fox Sports, FX Networks, Anheuser-Busch, GE, DirecTV, ESPN, The Weather Channel, Home Depot, and Coca-Cola.

I am the author of the open-source Gaia Framework for Adobe Flash, which dramatically reduces development time and makes developing Flash sites much easier.