|
how can I play an mp3 file in java?
hey, I've written something in another thread but it is a little old so...I hope you see it here..
I want to play an mp3 file and the code in eclipse is something like the following ... I see the interface but it can't be played...
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
public class AudioFilee extends JFrame {
public AudioFilee() {
setTitle("Music File");
setSize(300, 400);
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JButton s= new JButton("STOP");
JButton p= new JButton("PLAY");
JLabel j1 = new JLabel("MusicFile");
String[] musicfiles={"workspace/eclipse/Audio/asdf.mp3","asd.mp3"};
JComboBox musiclist=new JComboBox(musicfiles);
musiclist.setSelectedIndex(1);
jp1.add(j1);
jp1.add(musiclist);
jp2.add(s);
jp2.add(p);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
true, jp1, jp2);
splitPane.setOneTouchExpandable(true);
getContentPane().add(splitPane);
}
public static void main(String[] args) {
AudioFilee sp = new AudioFilee();
sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sp.setVisible(true);
}
}
Do you have any suggestion? Thanks
|