Reputation: 51
I use a Java applet, which produces unwanted sounds to me. Mute option in the applet is missing, and it's not possible to rewrite the source code. I want to hear other(non-JVM) applications' sounds. How do I suppress this Java applet(or JVM) sound output without disabling it?
I'm using Ubuntu 9.10, jre1.6.0_18 and Mozilla FF 3.5.8.
UPDATE:
Upvotes: 5
Views: 2210
Reputation: 57707
If you are in control of the deployment of the applet (I.e. the webpage hosting the applet), you could write your own Applet Launcher. The launcher functions as a wrapper that provides a custom environment to the actual applet. The launcher instantiates the real applet and passes to it customized versions of the applet environment (AppletStub, AppletContext.) The custom environment implements AudioClip as a "do nothing" interface.
To disable audio, you could override the AppletContext like this:
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() { }
}
We also override AppletStub, since this is where the Applet gets the AppletContext from
class CustomAppletStub implements AppletStub
{
AppletStub realStub;
public AppletContext getAppletContext()
{
return new CustomAppletContext(realStub.getAppletContext());
}
}
And then, your launcher:
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));
}
}
It looks like a lot of code, but it's really just a few classes and mostly wiring just to inject a new DummyAudioClip implementation.
HTH!
Upvotes: 3
Reputation: 175
I never encountered a problem like yours, but I removed pulseaudio completely and have never had any compaints since. In case, you want to go down that path, here are instructions for safely replacing pulseaudio with alsa.
Now, you can always use alsamixergui to manage sound for all apps.
Hope that solves your problem.
Upvotes: 1
Reputation: 31
It appears that Pulse stores the volume settings for individual applications in a Trivial Database (tbd) file in your home directory:(~/.pulse/(guid)-stream-volumes.tdb)
The tdbtool command from the Synaptic "tdb-tools" package can be used to inspect the records of this file, but it is not meant to be edited and appears to not be possible (except by someone with intimate knowledge of the pulse code) because all of the values are in hex format and are not easily readable or understood.
Upvotes: 1
Reputation: 667
I am wondering if a custom local security policy be able to stop the applet from accessing audio?
I didn't investigate it far (Googled the terms java applet local policy
)
http://www.wutka.com/hackingjava/ch3.htm#CreatingaCustomizedSecurityManager
The applet would probably exit with an exception if it fails loading the audio file or running the audio code, but it might be worth a shot.
Another short page http://www.jensign.com/JavaScience/www/policyfiles/
Upvotes: 1
Reputation: 19477
probably should be in power user. You can use pulse audio to control applications sounds(assuming you haven't disabled it) it should be in sound preferences. right click on the volume applet and open preferences click on application tab.
Upvotes: 1