Play mp3 files?

I am looking for a library that can play mp3 files. Also, the library must be able to set the position of the sound and as well as handling end events(for looping and starting point).

Look at mp3transform specifically…

Are you sure you need mp3 specifically? For game development and distribution, it is really not recommendable.

ClickerMonkey: Thanks, I will check it out soon.

Mads: The problem with wav files is that they are do damn big! For instance, the resources used in my game is about 300 mb. The music files, all wavs, make up to 80% of the files size. Each song is about 40-50 mb. Converting it to a mp3 would shrink the file size down to 3-5mb. Thats a big difference!

So in the end, its all about space and download time. People are lazy/have slow connections and dont want to download a unknown game that is 300+mb. So using mp3 files instead of wav for music is a must for me.

I agree with Mads. Why not using ogg instead? You won’t have any problem of licensing, no fee to pay, it is more widely supported by Java (look at Jogg, Jorbis and Paul Lamb Sound Library), ogg files are smaller than wav files.

What? Wait! Pay? Do I have to buy some licence for mp3 files? :o
Note that my game is 100% free(from abs as well) and open source.

Ogg = piss quality. So its not an option.

Ogg isn’t bad quality, what are you talking about? :V

Yes, mp3 is patented(in the US until 2017). In the case that you use the oracle implementation(JavaFX) Oracle will have paid the license fee for you I guess.

Also the quality of ogg is better than the one of mp3, i.e. id-Software uses it for its games. The best codec would be opus atm, but because of its young age you won’t find that many Java wrappers/implementations.

This is probably the most silly thing I have read on JGO this year, sorry.

Ogg is probably the most supported music file type out there for Java. I have no idea where you pulled that ridiculous statement from!

The reason I said ogg was bad is because the only times I have tried it was when I had converted a mp3 to an ogg, which is a bad idea. The quality loss is huge.
Most of my music files have been converted to wav from a mp3 file. So they are fake wavs. Converting these fake wavs to ogg will result in quality loss as well. High quality ogg can be archived by converting true wav files into ogg.

I will check javaFXs media player.

If you want to use openAL, there is paulsound. I have not used it before, but minecraft uses it, so it seems pretty good!

Well, there’s a simple solution; don’t convert your files that much. Its not fair to denounce the Ogg file type after you actively and knowingly sabotaged your experience with it.

I am not converting anything. Most sound files are already in mp3 format.

Is it a bad idea to convert a mp3(lossy) to ogg(lossy)? Are the quality loss in the converting process noticeable? Is it really that significant?

Converting from one lossy format to another is basically like replacing a your ruined tire with a ruined spare tire.

Your quality loss is as bad as going from a lossless to lossy, except it’s a lossy to a lossy, which means if you lose say 30% of your quality from lossless -> lossy, then you’d lose another 30% of the lossy, and you’d end up with only 49% initial quality, basically half artifact, half actual sound.

to quote some random guy in a forum that I found on google “When an already lossy audio format such as MP3 is transcoded to another lossy format such as AAC (or even to the same format) then there is an additional level of lossy data compression applied during the conversion. This is called generational loss and it results in further audio quality degradation. The more it’s done the worse it gets.”

That’s basically the best way to explain the problem with lossy to lossy conversion.

I converted a mp3 file to an ogg and the difference between the two files are so small that I am not sure if I am imagining it or not.

Please download and compare:
4.49mb Zip file:
http://www.mediafire.com/download/a425mqyiqkxa3e7/Music+Test.zip

I found an excellent way of “converting” a mp3 to ogg without any quality loss. You can record sound output with Audacity and export the sound to an ogg.
So I play the mp3 file in winamp or any other player, record the sound, export it to an ogg and done :slight_smile:

I’ve been using http://media.io for my audio file conversion. Its web based, free and has worked great for me so far.

j.