I have downloaded JMF MP3 PLUGIN to play mp3 files. After downloading i place mp3plugin.jar
into the project library of netbeans.
Then i start the code with the line :
import javax.media.*;
But there is an error corresponding to this statement which says package javax.media
does not exist. Why do i get this error ? I have tried searching about it but haven't found the solution. Please help me in this.
I have also placed C:\Program Files\Java\jdk1.7.0\jre\lib\ext\mp3plugin.jar
in the classpath variable.
It is not necessary to import a Service Provider Interface at compile time. Simply add it to the run-time class-path and it will be able to play mp3's as well as its (default) wave/pcm/midi files.
I use the mp3plugin.jar
this way for DukeBox, a little player for M3U style playlists, and it works just fine. Note that it will add the ability to read MP3 format using JavaSound (javax.sound.sampled
). If you intend playing the MP3 using the JMF player (which is unnecessary, and I do not recommend), you'll need to add the main JMF jar at both compile & run-time.
Here is an example code for playing sounds using JavaSound. Don't be put off by the length of the code, most of that is comments and explanation.
It will compile without importing any of JMF. If the mp3plugin.jar
is on the run-time class-path, it should be capable of playing MP3s.