Loading/Playing mp3s without round-tripping to the server

One of the cool new features of Flash Player 10 is that you can load files from the client without uploading them to the server.
The only limitation is that you`ll only be able to access the raw bytes of the file and there is no way to find out the filepath (see problem discussion here). The problem is that until now we cannot pass mp3 bytes to the sound object or the netstream class so there is no easy way to play mp3s locally on the client (without first uploading them to the server).
So here is a solution that uses the old trick of generating a SWF file in memory which contains the mp3 associated with a linkageId.

Check out my solution here
bild-7Note that some mp3s might not work as the Mp3Reader class is not very optimized but it should show the general steps to chieve the goal.
Let me know if it`s useful and if you could make any enhancements.

Next we`ll look into how to load two mp3s and mix them and save them as a wav (PCM) file.

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

5 thoughts on “Loading/Playing mp3s without round-tripping to the server

  1. Benjamin,

    You are a rockstar! This is very useful and I am sure there are many people looking for how to do just this. I am glad to see you are going to be working on your blog more again.

    Congratulations on the Community Expert achievement you deserve it!

    Thanks for all your posts and help.

    Arthur Nemirovsky

  2. Ben,

    Great job. Have you tried to do the same to load a FLV or an MP4?

    How would you do that?

    Take care,


  3. @Gilbert,

    Did you got that working? I did an implementation of some processes, only to find at the last step that I couldn’t hook my processed bytes in any way to a player (without writing to disk and/or doing it for the whole file – not an option in my scenario).

Leave a Reply

Your email address will not be published. Required fields are marked *