EvalSound function help with sound
I'm a teacher that created a spelling program for my kids that I use every day in my classroom. We just switched from XP to Windows 7 and now my program won't play the sounds. We also switched to netscape browser, which this program never worked in ( the sound bites are wav files). I need this program to work, but I just can't figure this out. I think it has to do wit the EvalSound function:
var thissound = eval("document." + soundobj);
thissound = null;
Some one ran a test for me on the site and it says: "uncaught type error: cannot call method 'play' of undefined"
How can I make this program work in Windows7 as well as in the netscape browser?
The <audio> tag DOES NOT WORK with ".wav" files in MSIE. Not even in MSIE 9.
The <embed> and <object> tags will work with ".wav" in MSIE.
But then I just noticed: "Netscape browser." ???? Netscape is officially *DEAD*. Why why why would you choose a browser that is completely obsolete, no longer supported by ANYBODY, will never be updated further, etc.??? Netscape was bought by AOL, but even AOL gave up on in it in February 2008 when it realized it could never keep up with the modern browsers, such as Chrome and Firefox. In any case, I'm pretty sure that <audio> was never implemented in ancient Netscape.
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
return (new Object());
window.open = SymWinOpen;
// helper function to play the sound
var thissound = eval("document." + soundobj);
thissound = null;
// an array of words
var wordArray = new Array(
// an array of sentences
var sentenceArray = new Array(
// global variable to represent the total number of words and sentences
// in the IE document.embed collection.
var totalEmbedCount = 0;
// function SelectWords
// This function will generate html and write it to document object.
// The html is randomly selected words from the wordArray or the sentenceArray
// arrays. The words are then added to the selectedArray.
// Do not allow duplicate words. This requires that the wordArray and
// sentence array have unique entries.
// array the array from which to select from
// maximumWords the number of words to randomly select from the numArr list
// the process:
// generate a random index in the numArr list.
// while the number of selected words is less than maximumWords
// if the value at the index was already selected,then
// select another random index
// add the indexed value to the selected value list
// write the html to the document
// store the indexed value in the document embed list
// end while
function SelectWords(array, maximumWords)
var selectedArray = new Array(); // the list of selected objects
var randomIndex = 0;
var selectedCount = 0;
var selectedWord = "";
// return if there are not enough words to select from
if(array.length < maximumWords)
// select maximumWords randomly selected words
while(selectedCount < maximumWords)
randomIndex = Math.round((array.length-1)*Math.random());
// save the randomly selected word for later use
selectedWord = array[randomIndex];
if(selectedArray[randomIndex] != randomIndex)
// store the index at the index to indicate that the index was selected.
selectedArray[randomIndex] = randomIndex;
// generate the html
document.embeds[totalEmbedCount].name = selectedWord;
// increment the selected word count.
// increment the total number of embed entries.
} // if (selectedArray[randomIndex] != randomIndex)
} // while(selectedIndex < maximumWords)
selectedArray = null;
array = null;
} // SelectWords
// note that these values are required to support the html below because there are
// 20 words in "Word List 1" and 5 sentences in "Sentence List 1"
// select 20 words from the word array.
// select 5 sentences from the sentence array.
Then I put the layout in a form so when the kids click a button it plays the word
<a href="#" onClick="EvalSound('embeds')">
</a><input type="hidden" Name="name1" Size="10" ID="Hidden2">
I just can't find the bug. any help suggested. I'm down to only 2 computers out of 6 that will play it now and I use it daily in my classroom.
i'm not sure what html5 is at this point; it's a lot more complex than when we had 2 browsers and 3 doctypes to contend with...
Ironically, firefox won't play MP3 in an audio tag, but will play wav just fine.
frustrating i know, but there are combos of browsers, formats, and code to work about everywhere; we can figure it out.
do you need it to work in IE, or is just firefox enough for this project?
The district has defaulted to Firefox, so I suppose it would be better if it worked in it. However, two computers are XP and 4 our win 7 I need it to work on all computers if possible. Any help would be so appreciated. I have 24 kids that take spelling tests twice a week and only 2 computers work. It really slows things down
I think this is becoming overly complicated. But the other thing is that the code you have is quite old, so it seems to me that it would be easier to rewrite than try to fix it and patch it here and there.
Can you explain in plain terms what the program is supposed to do? From what I gather, it takes all the sound files, jumbles them randomly then I guess the kid clicks a "play" button and the sounds play one by one.
And the sound files are all in .wav format and it only needs to work in firefox.
Is that correct?
My Spelling Rodeo takes 100 words and randomly selects 20. It also has 20 sentences and randomly selects 5.It then connects these words to buttons in a form. The kids click on the buttons to get their words.
After the kids are done, they submit form to me and it sends the list of words chosen to my email (on a side note, the list of words come with the .wav after it and I would love to have it get rid of the .wav and just give me the word). Yes, firefox would be the browser most used at school. I need to redo the sound bites for clarity, so I can change them to any format if that is helpful. I just don't have the know how to fix this.
Maybe you can use this for a start. I left the second lot of inputs visible for testing purposes, but you can hide them by adding
Works in Firefox and Chrome, won't work in IE <9
Can't get it to work!
I tinkered with your example all last night and part of today. I see what you've done (or I think I see), but when I loaded it up on page in firefox, there was no sound. It said error on page. I've attached a link here so you can see the format that I'm trying to achieve. The form is not fill in the blank. The kids listen to the audio and then write their words down on paper. They then submit it so that I get a list of what words they were given. That's great you got rid of the .wav thing! I was trying to figure out how to do a table so that I could have the buttons go across in 4 columns. I thank you so much for the help. I think it's best you just look at site.
Spelling Rodeo List 1
I ran the code I posted in Chrome and it works fine with your sound files. In firefox I get an error that says "Media resource http://spellingrodeocom.ipage.com/Sp...t%201/your.wav could not be decoded."
but running the code with my .wav files, it works fine in firefox
googling around, it seems that the problem could come from one of two issues:
- the MIME type of your files is not set correctly
- the bit rate is too high. It would appear that Firefox supports 8-bit and 16-bit PCM, but not other bit depths (12, 20, 24, 32).
maybe if you were going to re-record your audio files anyway it would make sense to do them in .ogg format which may be less problematic:
sorry, I don't know too much about audio so I'm not sure how much help I can be here
I have two more questions:
Is there a way to make the play sound buttons go 4 across by 5 rows? I've tried to put a table in the code, but can't seem to figure it out. Is there a way to assign each element pulled from the array to a specific cell?
Also, I have my sentences named senone.wav, sentwo.wav. That is what comes in the form to me when I go to grade. Is there any way give each sentence wav an id or name that can then be replaced in the form. What I'm trying to do is have the full sentence show in the form that is sent to me: ie. senone.wav = "He and I had the duck."
buttons and inputs are inline elements, so they will naturally (naturally?) go across the page. So all we have to do is add a line break after every fourth button and it kind of looks like a table. Add a little css and it looks alot like a table, without even having to make a table. Have a look and see what you think.
You can store the sentence text along with the file path, in objects. I've done the first six to give you an idea of the data structure. Feel free to ask if you get confused. The obvious downfall being that if any of your kids looks at the source code all the answers are there. But that's true for the single word files, anyway...
I'm assuming you have saved the new files with the different bit rates with different path names, as I tested this code with the old path names and got the same result - works in Chrome, not in FF...
|All times are GMT +1. The time now is 08:15 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.