Friday, August 5, 2011

Playing any Mp3 and stopping it using 2 line code ;)

Hello Fellaws,


Hope you are enjoying your java codes ;) :P


Well today i will provide you APIs to play mp3 songs using your own code ;)


I know it feels great playing your fav. songs using your code ;) ;) ;) <3


So lets begin below is the zip file containing 2 APIs
Download Here


This RavMp3APIs.zip contains 2 JAR files
1. RavMp3.jar   -> Contains the core code to play Mp3 Songs
2. RavMp3Support.jar   -> Contains Supporting files


So, just download this zip file and read the below steps to play Mp3 files ;)


Steps are as follows

  • Import these JAR files in your project. I am using NetBeans to develop my demo code. Steps are provided to import APIs in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above 2 JAR files
    • You are done with importing API in your project




  • Now Comes the code section, well to make it easy for you all. I have tried my level best to make the code short for you :) 
    • So, to play a Mp3 file you have to do 2 line coding
      • 1st Line -> PlayMp3 pm = new PlayMp3();     // Create PlayMp3 Object 
      • 2nd Line -> pm.playSong("D:\\Music\\Songs\\English Songs\\Lucky.mp3");   //call playSong(String son) method. NOTE: this methods take song's path as argument.
      • Optional Line -> pm.stopSong(); //to stop the song any time the user want 
    • Let me provide you a code with GUI that will make more clear about this API 



  • Congratulations, you developed your own Mp3 Player. Enjoy and Listen to your favorite Songs. :)


Thats it for this post


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

No comments:

Post a Comment