Search code examples
javascriptaudiomp3arrays

Turn byte array to sound


I have an mp3 file as byte array. How to turn it back to a sound and play using javascript?

Thanks


Solution

  • As far as I know this is decidedly non trivial.

    1. You can turn the array into a data URI, and then play it back normally.
    2. You can post it back to a server to do the encoding and play it back normally.
    3. You can use a fancy API

    2 seems inefficient, 3 requires browser specific support. So, use 1. I havent tried it, but check out http://www.bitsnbites.eu/?p=1. You should expect this to be way less efficient than native code.