Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascripting Sound objects

Status
Not open for further replies.

Kaitana

Programmer
Joined
Apr 19, 2002
Messages
5
Location
CA
Hello Guys, it has been a while since I have posted, and I apologise, but I have a really tough question, and no other board has been able to answer this one.

The website is a 'make me talk' website with a bunch of sound bite 'words' in a databse, and the user types in a sentence, and the cheracter talks.

The script I am having trouble with is looping through the embed tags, and playing the sounds in order. This is how it works so far:

I use embed tags to preload the files:
<embed name='zero' src = 'zero.wav' hidden='true' type='audio/wav' loop='1' AUTOSTART='FALSE'>
<embed name='one' src = 'one.wav' hidden='true' type='audio/wav' loop='1' AUTOSTART='FALSE'>


I then create objects to emulate the embed tags:

function soundbite(name, length)
{
this.name = name;
this.src = name + &quot;.wav&quot;;
this.hidden = true;
this.type = 'audio/wav';
this.loop = 1;
this.autostart = false;
this.length = length;
}
var bites = new Array();
bites[0] = new soundbite('zero', 490);
bites[1] = new soundbite('one', 640);

now is the tough part, and this is what I cannot seem to make work. I beed to use a setTimeout function to call the playit() function so the words are spaced properly:

setTimeout(&quot;playit(bites[0]);&quot;, bites[0].length);


the tough part is how do I access the document.embeds array to call the play() function?

//this function does not work..
function playIt(obj){
var snd = obj.name
alert(eval(document.embeds[snd]));
eval(document.embeds[snd]).play(true, obj.src)
}

This is a tough one. If anyone can help, I would be in debt.




 
If possible, I need to do this in IE also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top