Results 1 to 2 of 2
  1. #1
    iliana is offline Member
    Join Date
    May 2008
    Rep Power

    Default 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);



    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
    true, jp1, jp2);


    public static void main(String[] args) {

    AudioFilee sp = new AudioFilee();


    Do you have any suggestion? Thanks

  2. #2
    Master Zero is offline Member
    Join Date
    May 2008
    Rep Power


    You need to implement the action listener class and create the action performed method for your buttons, as event handlers. The link below shows you how to play audio files in java.

    Java Code:

Similar Threads

  1. How to play movie using java
    By sithara in forum New To Java
    Replies: 3
    Last Post: 02-20-2013, 01:29 PM
  2. How to play video files in Java
    By Hasan in forum Advanced Java
    Replies: 11
    Last Post: 04-26-2009, 11:57 PM
  3. play() and mp3
    By willemjav in forum Advanced Java
    Replies: 3
    Last Post: 12-23-2007, 03:50 PM
  4. Make sound play in a java application
    By lenny in forum AWT / Swing
    Replies: 2
    Last Post: 08-13-2007, 11:45 AM
  5. how to play MIDI in java application?
    By oregon in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 02:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts