I'm creating an audio player program in HTML and Javascript. How can I adjust the volume in my program?
我正在用HTML和Javascript创建一个音频播放器程序。如何调整程序中的音量?
2 个解决方案
#1
Changing the volumne requires access to the operating system's audio device driver or some abstraction layer.
更改volumne需要访问操作系统的音频设备驱动程序或某个抽象层。
The only way to change the volume is on Windows using ActiveX.
更改卷的唯一方法是在Windows上使用ActiveX。
#2
I'll assume that you're relying on the browser's default plugin to play the audio files. If you're using WMP through object elements, then you could dynamically change the settings using javascript.
我假设您依靠浏览器的默认插件来播放音频文件。如果您通过对象元素使用WMP,则可以使用javascript动态更改设置。
// get the element's DOM reference, replace to fit needs
obj = document.getElementById("player");
// set volume, 0=mute, 100=full
obj.Settings.volume = 50;
Combine that with a slider widget (i.e. jQuery UI), and that should work.
将它与滑块小部件(即jQuery UI)相结合,这应该可行。
reference: http://www.mioplanet.com/rsc/embed_mediaplayer.htm
#1
Changing the volumne requires access to the operating system's audio device driver or some abstraction layer.
更改volumne需要访问操作系统的音频设备驱动程序或某个抽象层。
The only way to change the volume is on Windows using ActiveX.
更改卷的唯一方法是在Windows上使用ActiveX。
#2
I'll assume that you're relying on the browser's default plugin to play the audio files. If you're using WMP through object elements, then you could dynamically change the settings using javascript.
我假设您依靠浏览器的默认插件来播放音频文件。如果您通过对象元素使用WMP,则可以使用javascript动态更改设置。
// get the element's DOM reference, replace to fit needs
obj = document.getElementById("player");
// set volume, 0=mute, 100=full
obj.Settings.volume = 50;
Combine that with a slider widget (i.e. jQuery UI), and that should work.
将它与滑块小部件(即jQuery UI)相结合,这应该可行。
reference: http://www.mioplanet.com/rsc/embed_mediaplayer.htm