[英]Mute sound in Java Applet
我使用Java applet,它會給我帶來不必要的聲音。 applet中的靜音選項丟失,無法重寫源代碼。 我想聽聽其他(非JVM)應用程序的聲音。 如何在不禁用此Java applet(或JVM)聲音輸出的情況下抑制它?
我使用的是Ubuntu 9.10,jre1.6.0_18和Mozilla FF 3.5.8。
更新:
如果您控制applet的部署(即托管applet的網頁),您可以編寫自己的Applet Launcher。 啟動器用作包裝器,為實際的applet提供自定義環境。 啟動器實例化真實的applet並傳遞給applet環境的自定義版本(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實現。
HTH!
可能應該是超級用戶。 您可以使用脈沖音頻來控制應用程序聲音(假設您沒有禁用它)它應該是聲音偏好。 右鍵單擊卷小程序並打開首選項單擊應用程序選項卡。
我想知道自定義本地安全策略是否能夠阻止applet訪問音頻? 我沒有調查它(谷歌搜索條款java applet local policy
)
http://www.wutka.com/hackingjava/ch3.htm#CreatingaCustomizedSecurityManager
如果加載音頻文件或運行音頻代碼失敗,applet可能會以異常退出,但它可能值得一試。
Pulse似乎將各個應用程序的卷設置存儲在主目錄中的Trivial Database(tbd)文件中:(〜/ .pulse /(guid)-stream-volumes.tdb)
來自Synaptic“tdb-tools”軟件包的tdbtool命令可以用來檢查這個文件的記錄,但它不是要編輯的,看起來是不可能的(除非是對脈沖代碼有深入了解的人),因為所有值都是十六進制格式,不易讀取或理解。
我從來沒有遇到像你這樣的問題,但我完全刪除了pulseaudio,從那時起就沒有任何過程。 如果您想沿着這條路走下去,這里有一些安全地用alsa替換pulseaudio的說明。
現在,您始終可以使用alsamixergui來管理所有應用的聲音。
希望能解決你的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.