/////////////////////////////////////////////// // Java 2 APPLET zAudio.java // Wilucha 13/07/03 // ////////////////////////////////////////////// import java.awt.Graphics; import java.applet.AudioClip; public class zAudio extends java.applet.Applet implements Runnable { AudioClip SonidoFondo; AudioClip OtroSonido; Thread MusicaMaestro; public void start() { if (MusicaMaestro == null) { MusicaMaestro = new Thread(this); MusicaMaestro.start(); } } public void stop() { if (MusicaMaestro != null) { if (SonidoFondo != null) SonidoFondo.stop(); MusicaMaestro = null; } } public void init() { SonidoFondo = getAudioClip(getCodeBase(),"tema1.wav"); OtroSonido = getAudioClip(getCodeBase(), "tema2.wav"); } public void run() { if (SonidoFondo != null) SonidoFondo.loop(); Thread thisThread = Thread.currentThread(); while (MusicaMaestro == thisThread) { try { Thread.sleep(5000); } catch (InterruptedException e) { } if (OtroSonido != null) OtroSonido.play(); } } public void paint(Graphics screen) { screen.drawString("Música maestro ...", 10, 10); } }