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 + ".wav";
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("playit(bites[0]);", 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.
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 + ".wav";
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("playit(bites[0]);", 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.