Wednesday 16 July 2014

Program to play and stop music on your choice in java applet

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class mus3 extends Applet
implements ActionListener{
   Button play,stop;
   AudioClip audioClip;
   public void init(){
      play = new Button("  Play ");
      add(play);
      play.addActionListener(this);
      stop = new Button("  Stop  ");
      add(stop);
      stop.addActionListener(this);
      audioClip = getAudioClip(getCodeBase(), "mus.wav");
   }
   public void actionPerformed(ActionEvent ae){
      Button source = (Button)ae.getSource();
      if (source.getLabel() == "  Play  "){
         audioClip.play();
      }
      else if(source.getLabel() == "  Stop  "){
         audioClip.stop();
      }
   }
}

No comments:

Post a Comment

SAY HELLO!!