java.applet

Interface AudioClip

public interface AudioClip

The AudioClip interface is a simple abstraction for playing a sound clip. Multiple AudioClip items can be playing at the same time, and the resulting sound is mixed together to produce a composite.
Since:
JDK1.0

Method Summary

void
loop()
Starts playing this audio clip in a loop.
void
play()
Starts playing this audio clip.
void
stop()
Stops playing this audio clip.

Method Details

loop

public void loop()
Starts playing this audio clip in a loop.
Usages and Demos :

View More Examples of loop()
   1: {
   2:     AudioClip ac;
   3:     Button btnStart=new Button("????????");
   4:         ...
   5:         if( ac==null ){
   6:             System.out.println("AudioClip object is not created!");
   7:             return;
   8:         ...
   9:             ac.play();
  10:             ac.loop();
  11:         }else if( cmd == btnPause ){
  12:         ...
  13:             ac.play();
  14:             ac.loop();

View Full Code Here
   1: public class Exercise16_20 extends JApplet implements ActionListener {
   2:   private AudioClip audioClip;
   3:   private JButton jbtPlay, jbtLoop, jbtStop;
   4:         ...
   5:     URL url = this.getClass().getResource("ticker.au");
   6:     audioClip = Applet.newAudioClip(url);
   7: 
   8:         ...
   9:     else if (actionCommand.equals("Loop")) {
  10:       audioClip.loop();
  11:     }

View Full Code Here
   1:   private boolean isStandalone = false;
   2:   AudioClip music;
   3:   Button button1=new Button();
   4:         ...
   5:   void button1_actionPerformed(ActionEvent e) {
   6:         music.loop();
   7:   }
   8: 
   9:   void button2_actionPerformed(ActionEvent e) {

View Full Code Here
   1: public class Exercise29_8 extends JFrame implements ActionListener {
   2:   private AudioClip audioClip;
   3:   private JButton jbtPlay = new JButton("Play");
   4:         ...
   5:     url = this.getClass().getResource("/audio/china.mid");
   6:     audioClip = Applet.newAudioClip(url);
   7: 
   8:         ...
   9:     else if (actionCommand.equals("Loop")) {
  10:       audioClip.loop();
  11:     }

View Full Code Here
   1:     JTextField urlField;
   2:     AudioClip clip;
   3: 
   4:         ...
   5:         } else if (source == loopButton ) {
   6:             clip.loop();
   7:         }
   8:     }

View Full Code Here

play

public void play()
Starts playing this audio clip. Each time this method is called, the clip is restarted from the beginning.
Usages and Demos :

View More Examples of play()
   1: {
   2:     AudioClip click;
   3: 
   4:         ...
   5:         {
   6:             click.play();
   7:         }
   8:     }
   9: }

View Full Code Here
   1: import java.applet.Applet;
   2: import java.applet.AudioClip;
   3: import java.net.URL;
   4:         ...
   5: 
   6:             c.play();
   7:             Thread.sleep(2000);
   8: 

View Full Code Here
   1: 
   2:   AudioClip theGong;
   3:   Thread t;
   4:         ...
   5:     while (true) {
   6:       theGong.play();
   7:       try {
   8:         Thread.sleep(5000);
   9:       }

View Full Code Here
   1:     java.io.File file = new java.io.File( args[0] );
   2:     final AudioClip sound = Applet.newAudioClip(file.toURL(  ));
   3: 
   4:         ...
   5:     button.addActionListener(new ActionListener(  ) {
   6:       public void actionPerformed(ActionEvent e) { sound.play(  ); }
   7:     });
   8: 
   9:     Container content = frame.getContentPane();

View Full Code Here
   1: {
   2:     AudioClip ac;
   3:     Button btnStart=new Button("????????");
   4:         ...
   5:         if( ac==null ){
   6:             System.out.println("AudioClip object is not created!");
   7:             return;
   8:         ...
   9:         if ( cmd == btnStart ){
  10:             ac.play();
  11:             ac.loop();
  12:         ...
  13:         }else if( cmd == btnContinue ){
  14:             ac.play();

View Full Code Here

stop

public void stop()
Stops playing this audio clip.
Usages and Demos :

View More Examples of stop()
   1: {
   2:     AudioClip ac;
   3:     Button btnStart=new Button("????????");
   4:         ...
   5:         if(ac!=null)
   6:             ac.stop(); 
   7:     }
   8:         ...
   9:         if( ac==null ){
  10:             System.out.println("AudioClip object is not created!");
  11:             return;
  12:         ...
  13:         }else if( cmd == btnPause ){
  14:             ac.stop();

View Full Code Here
   1: 
   2:     AudioClip snd = null;
   3: 
   4:         ...
   5:     public void stop() {
   6:         System.out.println("In AppletMethods.stop()");
   7:         if (snd != null)
   8:     }

View Full Code Here
   1: public class Exercise16_20 extends JApplet implements ActionListener {
   2:   private AudioClip audioClip;
   3:   private JButton jbtPlay, jbtLoop, jbtStop;
   4:         ...
   5:     URL url = this.getClass().getResource("ticker.au");
   6:     audioClip = Applet.newAudioClip(url);
   7: 
   8:         ...
   9:     else if (actionCommand.equals("Stop")) {
  10:       audioClip.stop();
  11:     }

View Full Code Here
   1:   private boolean isStandalone = false;
   2:   AudioClip music;
   3:   Button button1=new Button();
   4:         ...
   5:   void button2_actionPerformed(ActionEvent e) {
   6:        music.stop();
   7:   }
   8: }

View Full Code Here
   1: 
   2:     AudioClip snd = null;
   3: 
   4:         ...
   5:     public void stop() {
   6:         System.out.println("Dans AppletMethods.stop()");
   7:         if (snd != null)
   8:     }

View Full Code Here