MP3 playback using Java Sound and Sun MP3 plugin

D

Daniel Dyer

I downloaded Sun's plugin for MP3 support
(http://java.sun.com/products/java-media/jmf/mp3/download.html). The
website seems to suggest that it will work with the Java Sound APIs
without any need to install the Java Media Framework. However, I can only
get it to work with the Java Sound classes when the JMF is also installed
(I've tried on Windows and Linux).

Has anybody managed to get it to work without installing the JMF?

I'm aware that I can use the MP3SPI/JLayer libs from JavaZoom, but I'd
like to get it working with Sun's stuff if possible (performance and
licensing being the main reasons). Does anyone know of any other pure
Java MP3 player libraries?

Thanks,

Dan.
 
D

Daniel Dyer

I downloaded Sun's plugin for MP3 support
(http://java.sun.com/products/java-media/jmf/mp3/download.html). The
website seems to suggest that it will work with the Java Sound APIs
without any need to install the Java Media Framework. However, I can
only get it to work with the Java Sound classes when the JMF is also
installed (I've tried on Windows and Linux).

Has anybody managed to get it to work without installing the JMF?

I should probably specify the error I'm seeing. I get the following
exception when I call the getAudioInputStream method of the
javax.sound.sampled.AudioSystem class and pass it an MP3 file:

javax.sound.sampled.UnsupportedAudioFileException: could not get audio
input stream from input file
at
javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1170)

Dan.
 
D

Daniel Dyer

It is part of JMF, just a Johnny come lately part as I understand it.

See http://mindprod.com/jgloss/jmf.html

The download page says:

"The included jar file (mp3plugin.jar) contains a Java Sound plugin as
well as a Java Media Framework plugin for playing MPEG-2 Layer 3 Audio."

....and then goes on to describe two installation steps, one to get it to
work with Java Sound and an additional step to get it to work with the
JMF. I'm not using any of the JMF classes directly, I'm just using
javax.sound.sampled.* rather than javax.media.*, but it only seems to work
if the JMF is installed. I would expect a ClassDefNotFoundError or
similar, rather than the UnsupportedAudioFileException that I am getting,
if it was reliant on the JMF classes.

Dan.
 
K

Knute Johnson

Daniel said:
The download page says:

"The included jar file (mp3plugin.jar) contains a Java Sound plugin as
well as a Java Media Framework plugin for playing MPEG-2 Layer 3 Audio."

...and then goes on to describe two installation steps, one to get it
to work with Java Sound and an additional step to get it to work with
the JMF. I'm not using any of the JMF classes directly, I'm just
using javax.sound.sampled.* rather than javax.media.*, but it only
seems to work if the JMF is installed. I would expect a
ClassDefNotFoundError or similar, rather than the
UnsupportedAudioFileException that I am getting, if it was reliant on
the JMF classes.

Dan.

Daniel:

I ran into the same problems that you have seen. The MP3 plugin will
work with JavaSound but it only works with certain format MP3 files.
Apparently (and I am not that knowledgable in this area) there are many
different types of MP3 files. JMF will apparently play more different
file types.

There is a really good JavaSound email list

http://java.sun.com/products/java-media/sound/list.html

and you should look into Tritonus. These fellows have written some
really handy things, MP3 too, for JavaSound.

www.tritonus.org

One of the guys on the list was the Sun guy for JavaSound for a couple
of years and is really knowledgable and very helpful.
 
D

Daniel Dyer

I ran into the same problems that you have seen. The MP3 plugin will
work with JavaSound but it only works with certain format MP3 files.
Apparently (and I am not that knowledgable in this area) there are many
different types of MP3 files. JMF will apparently play more different
file types.

There is a really good JavaSound email list

http://java.sun.com/products/java-media/sound/list.html

Thanks, I will take a look.
and you should look into Tritonus. These fellows have written some
really handy things, MP3 too, for JavaSound.

www.tritonus.org

I was looking at the Tritonus stuff, but I wasn't sure exactly what it
was. It seems to be a pure Java implementation of Java Sound that was
written primarily for Linux. Is that correct?

I know the MP3SPI library uses it. I hacked around in the source code to
try and remove the dependency and see if MP3SPI would work just using the
base Java Sound classes, but I didn't get it to work properly.

There's no reason why I can't use Tritonus (or why I can't install JMF), I
just thought it should be possible to play MP3s without either.

Thanks,

Dan.
 
K

Knute Johnson

Daniel said:
I was looking at the Tritonus stuff, but I wasn't sure exactly what it
was. It seems to be a pure Java implementation of Java Sound that was
written primarily for Linux. Is that correct?

I think you are right, they are primarily Linux guys, but Tritonus will
run just fine on any Java system.
I know the MP3SPI library uses it. I hacked around in the source code
to try and remove the dependency and see if MP3SPI would work just
using the base Java Sound classes, but I didn't get it to work properly.

There's no reason why I can't use Tritonus (or why I can't install JMF),
I just thought it should be possible to play MP3s without either.

The nice thing about the Tritonus is that it is just a couple of JAR
files any you are ready to go. Ask around on the JAVASOUND mailling
list, I'm sure they can get you running with the plugin. I just didn't
get where I was going with it and moved on to something else. I'm sure
it will work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top