hi, are there any libraries that would convert mp3 files to bytebuffer for me? Or can built in java methods do it for me?
Did you try just reading it in as bytes. Even an mp3 file is nothing but a string of characters. Making your reader understand it so you can play music… that is another thing entirely.
Guess what I need?
You probably should use ogg instead of mp3 (better quality + patent free).
There is also this sound lib called TinySound which is from a member of this forum I think, which can play such files.
If you actually need the raw audio data: http://stackoverflow.com/questions/938304/how-to-get-audio-data-from-a-mp3
Note that the byte buffer required will be significantly (2-3 times) larger than the mp3 file itself. To calculate size required, multiply samples in the file by bytes per sample:
long bytesReq = stream.getFrameLength() * format.getSampleSizeInBits() / 8;
Depending on the required functionality and how lazy you are, you could avoid large storage of data and stream it in as you need it, as the SO answer above returns an AudioStream.
Also, Danny’s advice is good advice.