Play mp3 Using   Jlayer

Picture
Hello Friends im sameera here.today im going to teach about how to play mp3 using java.it is pretty easy.you dont wonna worry,i teach every step :) ok
before we start our lesson we need to find some mp3 and download jlayer
you can just google as jlayer download
or i ll give download link hmm,i ll give the download link below.its easy nothing to serf :D
our porpose is when we paly main class it linked with another java form,we put jlable to jframe and it shows some word like "Mp3 is playing".it is additional step if u dont like it so don't do it :)
i use Do while loop for this becorse,if their isnt a loop the mp3 is play only one time,but we apply loop so it works till the condition goes  false.
here is the way to write do while loop.dont worry i teach some lessons about loops :)
this is for additional knowledge
do{ statement to do you wanna do     }
while
( condition true);

and also i use try catch in here because it prevent the exceptions and handle it.
i apply do while loop and try catch as this
 int i=0;
      do{
          try {
              FileInputStream file=new FileInputStream("C:\\Documents and Settings\\Sameera\\Desktop\\bl.mp3");
              Player playmp3=new Player(file);
              playmp3.play();
          } catch (Exception e) {
          }     
 }while(i<10);and full code in main class is like this:
package java2zmp3;
import java.io.FileInputStream;
import javazoom.jl.player.Player;
public class Main {   
     public static void main(String[] args) {    
  new Welcome().setVisible(true);  
    int i=0;    
  do{   
       try {       
       FileInputStream file=new FileInputStream("C:\\Documents and Settings\\Sameera\\Desktop\\bl.mp3");     
         Player playmp3=new Player(file);          
    playmp3.play();        
  } 
catch (Exception e) {          }  
    }
while(i<10);   
 }
}
watch the video and have fun don't forget to say thank thanks.

Download jlayer
http://ity.im/0rN9d


watch on youtube

http://www.youtube.com/watch?v=655reawVe9Mweeblylink_new_window

 download this video

http://ity.im/0rN9e
Download Netbens Project
http://www.mediafire.com/?w9hxs6aeepa7fs7weeblylink_new_window
Hint :
i genarate some codings by typing few letters and press ctrl+space :)


kushan
8/18/2011 02:34:46 am

wooooow.... elazzz sameera aiyaa. i think this is a very use fl tutorial. also wish u al d best. keep it up aiyyaaa..

Reply



Leave a Reply.