.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> OOPS >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Java program to play audio.

Posted By:laptop charles       Posted Date: June 30, 2010    Points: 10    Category: OOPS    URL: http://www.dotnetspark.com  

Play the audio.
 

It contain a audio format with the class ,it simply play the audio.
play,pause and stop then next song.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;
//import java.util.*;

public class audio extends Applet implements ActionListener,ItemListener
     {
      AudioClip so1,so2,cur;
      Button play,loop,stop;
      Choice cho;
      public void init()
      {
        cho=new Choice();
        cho.addItem("kuz");
        cho.addItem("CHARLES");
        cho.addItemListener(this);

        play=new Button("play");
        loop=new Button("loop");
        stop=new Button("stop");
        
        play.addActionListener(this);
        loop.addActionListener(this);
        stop.addActionListener(this);
        
        add(cho);

        add(play);
        add(loop);
        add(stop);

                         so1=getAudioClip(getCodeBase(),"kuzalum.wav");
        so2=getAudioClip(getCodeBase(),"ammane.wav");
        cur=so1;
       }   
 
      public void actionPerformed(ActionEvent ae)
         {
          if(ae.getSource()==play)
             {
              cur.play();
             }
          else if(ae.getSource()==loop)
             {
              cur.loop();
             }
          else if(ae.getSource()==stop)
             {
              cur.stop();
             }
          }

public void itemStateChanged(ItemEvent e)
   {
     int v=cho.getSelectedIndex();
     if(v==0)
         cur=so1;
      else
          cur=so2;
   }
}

/*


*/

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend