English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Can you use javascript to change the volume of embedded music?

the music would be:



If I want the volume to be changed to another value, say 100, once a button or link is clicked, how should i do this? The following is not working for me.

function change_volume() {
document.getElementById("music").volume = "100";
}

are there any ways to do this? Please give me an simple answer if possible^^"~

2007-03-24 17:59:26 · 2 answers · asked by cherri_pwincesu 1 in Computers & Internet Programming & Design

2 answers

The only way to do it is to specify your embedded application. By simply specifying "embed" and the file name, you are allowing the client browser to select the associated application to actually play the file. When the browser instanciates the page, it passes the initialization variables (filename, volume, etc.) to the associated handler application, and has no more hand in it from there on out - the space in the page where the application takes over is not a part of the browser space - rather, it is demarcated by the browser as "leased space" to application xx, and that's all the browser knows. Since application does not interact directly with the browser (and hence the HTML and JavaScript in the page) after it loads, and the player APIs and hooks are different for every application, there is no way to control it directly through the DOM. The only way is to utilize a specific player - that is, explicitly instanciate a Windows Media Player plugin, a Real Plugin, QuickTime, or Flash. Each of these has its own documentation on how to invoke commands on the plugin object from JavaScript. I recommend Flash since it has the widest installation base, lightweight delivery, and the best-established methods for interacting with JavaScript.

2007-03-24 18:02:33 · answer #1 · answered by Rex M 6 · 1 1

use tag if you want to change the volume of the sound.

(Separated javascript to avoid hidden information, please join it back after this)

the volume must be 0 to -10000
where 0 is the normal and -10000 is mute

document.
getElementsBy
TagName
("bgsound")
[0].
volume = "-2000"

2007-03-24 20:10:48 · answer #2 · answered by Anonymous · 0 1

fedest.com, questions and answers