?
Solved

Playing Sound in a Web Page

Posted on 2007-08-02
11
Medium Priority
?
445 Views
Last Modified: 2013-12-08
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.
0
Comment
Question by:Richard Korts
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:avris
ID: 19622184
Have you tried:
 var thissound= eval("document.getElementById('"+soundobj+"')")

<embed src="sounds/u2_q1_j.wav" autostart=false hidden=true id="sound1" enablejavascript="true">

?

0
 
LVL 8

Expert Comment

by:ilovemykeyki
ID: 19622369
1)
<form>
<input type="button" value="Play Sound" onClick="EvalSound('sound1')">
</form>
2)
<script>
function EvalSound(soundobj) {
  var thissound=document.getElementById(soundobj);
  thissound.Play();
}
</script>
3)
<embed src="success.wav" autostart=false width=0 height=0 id="sound1"
enablejavascript="true">

0
 
LVL 8

Expert Comment

by:ilovemykeyki
ID: 19622374
its because newer browsers doesnt support it anymore. :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 19623259
More likely Quicktime was installed since then and that plugin does not understand Play()
0
 

Author Comment

by:Richard Korts
ID: 19625933
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.
0
 

Author Comment

by:Richard Korts
ID: 19625954
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?
0
 
LVL 8

Expert Comment

by:ilovemykeyki
ID: 19633747
hi..i already put the code above. see the 2nd reply. thanks.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 19640716
0
 

Author Comment

by:Richard Korts
ID: 19647804
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
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19945047
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question