My logic for run background music when click button.

        b.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)
            {
                ContinuousAudioDataStream loop=null;

                AudioPlayer mgp=AudioPlayer.player;
                try{
                AudioStream bgm=new AudioStream(new FileInputStream("C:/Users/Public/Music/Sample Music/Sleep Away.mp3"));
                AudioData md=bgm.getData();
                loop=new ContinuousAudioDataStream(md);

                }
                catch(IOException ex){

                }
                mgp.start(loop);
                loop=null;
            }
        });

Hello EveryOne,

I am new to Java and creating a small program to add background music but its not working.
I have one qury do I need to add any .jar file in my lib folder for sound?

Thanks

Dont leave the catch block empty. Add ex.printStackTrace() in the catch block. So that you will know the errors if any. (Remember : Never ever leave the catch block empty in you whole programming life because that will make your life worse:) )

And you do not need to add any jar file unless you use third-party libraries.