Muting a Java applet

I use a Java applet that creates unwanted sounds for me. There is no option to mute the sound in the applet, and it is impossible to rewrite the source code. I want to hear the sounds of other (non-JVM) applications. How can I suppress sound using a Java applet (or JVM) without disabling it?

I am using Ubuntu 9.10, jre1.6.0_18 and Mozilla FF 3.5.8.

UPDATE:

  • The Java applet is missing from the “Sound Settings → Applications” section because the sounds are too short (“beep”, etc.).
  • When another application creates sounds (.mp3, .ogg music), the java applet does not.
+5
source share
5 answers

(, -, ), . , . Launcher (AppletStub, AppletContext.) AudioClip " ".

, AppletContext :

class CustomAppletContext implements AppletContext
{
    AppletContext realContext;

    // most methods delegate to the real context, either directly, or with a little modification to hide the fact that we are using this launcher
   public void setStatus(String status)
   {
       realContext.setStatus(status);
   }

   // override the getAudioClip to return a dummy clip
   public AudioClip getAudioClip(URl url)
   {
       return new DummyAudioClip();
   }
}

// An AudioClip implementation that does nothing
class DummyAudioClip implements AudioClip
{
    public void loop() { }
    public void play() { }
    public void stop() { }
}

AppletStub, Applet AppletContext

class CustomAppletStub implements AppletStub
{
    AppletStub realStub;

    public AppletContext getAppletContext()
    {
        return new CustomAppletContext(realStub.getAppletContext());
    }
}

, :

class AppletLauncher extends Applet
{
    private Applet   realApplet = new NoisyApplet();

    // delegate most methods to the applet, but override the stub, to inject our
    // AppletContext and AudioClip implementation

    public void setAppletStub(AppletStub stub)
    {
        realApplet.setAppletStub(new CustomAppletStub(stub));
    }
}

, , , DummyAudioClip.

!

+3

, . ( , ) . .

+1

, Pulse Trivial Database (tbd) : (~/.pulse/(guid) -stream-volume.tdb)

tdbtool Synaptic "tdb-tools" , ( - ), .

+1

, , pulseaudio . , , pulseaudio alsa.

  • sudo apt-get purge pulseaudio gstreamer0.10-pulseaudio
  • sudo apt-get autoremove
  • sudo apt-get install alsa-base alsa-tools alsa-tools-gui alsa-utils alsa-oss linux-sound-base alsamixergui
  • sudo apt-get install esound esound-clients esound-common libesd-alsa0 gnome-alsamixer
  • Restart your computer!
  • gstreamer-properties ---- set ALSA as default

Now you can always use alsamixergui to control sound for all applications.

Hope that solves your problem.

+1
source

All Articles