Richard Korts
asked on
Playing Sound in a Web Page
We have a web application that was built several years ago. It uses .wav files containing sound clips. The sound clips are played when the user clicks a button on the web page.
The application has been in "mothballs" for several years. We recently recussitated it & now it fails in Internet Explore. It seems to work (sometimes) in Firefox.
The following is an example of the combination of HTML / Javascript that is used to play the sound clips.
(1) Form button looks like this:
<input type="button" value="Go" class="pt8" name="go1" onClick="EvalSound('sound1 ')">
(2) Javascript function EvalSound:
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj) ;
thissound.Play();
}
(3) sound1 defined:
<embed src="sounds/u2_q1_j.wav" autostart=false hidden=true name="sound1" enablejavascript="true">
When this is now run in IE 6.0, a Javascript Error occurs as follows:
"Object doesn't support this property or method.", line 79. Line 79 is
thissound.Play(); in the function EvalSound.
Why doesn't this work anymore? In Nov. 2005 it worked fine.
The application has been in "mothballs" for several years. We recently recussitated it & now it fails in Internet Explore. It seems to work (sometimes) in Firefox.
The following is an example of the combination of HTML / Javascript that is used to play the sound clips.
(1) Form button looks like this:
<input type="button" value="Go" class="pt8" name="go1" onClick="EvalSound('sound1
(2) Javascript function EvalSound:
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj)
thissound.Play();
}
(3) sound1 defined:
<embed src="sounds/u2_q1_j.wav" autostart=false hidden=true name="sound1" enablejavascript="true">
When this is now run in IE 6.0, a Javascript Error occurs as follows:
"Object doesn't support this property or method.", line 79. Line 79 is
thissound.Play(); in the function EvalSound.
Why doesn't this work anymore? In Nov. 2005 it worked fine.
1)
<form>
<input type="button" value="Play Sound" onClick="EvalSound('sound1 ')">
</form>
2)
<script>
function EvalSound(soundobj) {
var thissound=document.getElem entById(so undobj);
thissound.Play();
}
</script>
3)
<embed src="success.wav" autostart=false width=0 height=0 id="sound1"
enablejavascript="true">
<form>
<input type="button" value="Play Sound" onClick="EvalSound('sound1
</form>
2)
<script>
function EvalSound(soundobj) {
var thissound=document.getElem
thissound.Play();
}
</script>
3)
<embed src="success.wav" autostart=false width=0 height=0 id="sound1"
enablejavascript="true">
its because newer browsers doesnt support it anymore. :)
More likely Quicktime was installed since then and that plugin does not understand Play()
ASKER
To mplungian:
It needs to work on any computer regardless of whether Quicktime or Real Player are installed.
But as a test, should I uninstall Quicktime? I doubt that is the issue since it fails with a JavaScript error IN THE BROWSER.
It needs to work on any computer regardless of whether Quicktime or Real Player are installed.
But as a test, should I uninstall Quicktime? I doubt that is the issue since it fails with a JavaScript error IN THE BROWSER.
ASKER
To ilovemykeyki:
"its because newer browsers doesnt support it anymore. :)" - Can you provide me with code that will work WITHOUT requiring a QuickTime or RealPlayer plugin?
"its because newer browsers doesnt support it anymore. :)" - Can you provide me with code that will work WITHOUT requiring a QuickTime or RealPlayer plugin?
hi..i already put the code above. see the 2nd reply. thanks.
Convert it to mp3 and use
http://www.boutell.com/newfaq/creating/audio.html
http://www.boutell.com/newfaq/creating/audio.html
ASKER
To ilovemykeyki:
I tried your code & it works! But there is one issue. It uses Real Player to play the sound & opens a Real Player object. Is there a way to minimize that object so that it DOES NOT appear on the screen?
Thanks,
rkorts
I tried your code & it works! But there is one issue. It uses Real Player to play the sound & opens a Real Player object. Is there a way to minimize that object so that it DOES NOT appear on the screen?
Thanks,
rkorts
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var thissound= eval("document.getElementB
<embed src="sounds/u2_q1_j.wav" autostart=false hidden=true id="sound1" enablejavascript="true">
?