Java Applet 中的静音
我使用 Java 小程序,它会产生我不想要的声音。 小程序中缺少静音选项,并且无法重写源代码。 我想听听其他(非 JVM)应用程序的声音。 如何在不禁用此 Java applet(或 JVM)声音输出的情况下抑制它?
我使用的是 Ubuntu 9.10、jre1.6.0_18 和 Mozilla FF 3.5.8。
更新:
- “声音首选项 -> 应用程序”中缺少 Java 小程序,因为声音太短(“蜂鸣声”等)。
- 当其他应用程序产生声音(.mp3、.ogg 音乐)时,java 小程序不会。
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:
- Java applet is missing in "Sound preferences->Applications", because sounds are too short("beep" etc.).
- When other application produces sounds(.mp3, .ogg music) java applet doesn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您可以控制小程序的部署(即托管小程序的网页),您可以编写自己的小程序启动器。启动器充当包装器,为实际小程序提供自定义环境。启动器实例化真正的小程序,并将小程序环境的自定义版本(AppletStub、AppletContext)传递给它。自定义环境将 AudioClip 实现为“不执行任何操作”接口。
要禁用音频,您可以像这样重写 AppletContext:
我们还重写 AppletStub,因为这是 Applet 从中获取 AppletContext 的地方
然后,您的启动器:
它看起来像很多代码,但实际上只是几个类,而且大部分连接只是为了注入新的 DummyAudioClip 实现。
哈!
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:
We also override AppletStub, since this is where the Applet gets the AppletContext from
And then, your launcher:
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!
可能应该是高级用户。
您可以使用脉冲音频来控制应用程序声音(假设您尚未禁用它)
它应该符合合理的偏好。
右键单击音量小程序并打开首选项,然后单击应用程序选项卡。
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.
我想知道自定义本地安全策略是否能够阻止小程序访问音频?
我没有调查太多(谷歌搜索了术语
java applet本地策略
)http://www.wutka.com/hackingjava/ch3.htm#CreatingaCustomizedSecurityManager
如果加载音频文件或运行音频代码失败,小程序可能会退出并出现异常,但这可能是值得的一枪。
另一个短页
http://www.jensign.com/JavaScience/www/policyfiles/
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/
看来 Pulse 将各个应用程序的卷设置存储在主目录中的普通数据库 (tbd) 文件中:(~/.pulse/(guid)-stream-volumes.tdb)
来自 Synaptic“tdb-tools”的 tdbtool 命令“包可用于检查该文件的记录,但它并不意味着可以编辑,并且似乎不可能(除非对脉冲代码有深入了解的人),因为所有值都是十六进制格式并且是不容易阅读或理解。
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.
我从来没有遇到过像你这样的问题,但我完全删除了pulseaudio,从那以后再也没有遇到过任何抱怨。如果您想沿着这条路走下去,这里有关于用 alsa 安全替换pulseaudio 的说明。
现在,您始终可以使用 alsamixergui 来管理所有应用程序的声音。
希望能解决您的问题。
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.