robertybob
asked on
Playing sounds and manipulating sound files
Hi.
Firstly, this is for audible alerts so is a valid reason for having sound on a page :)
I have 2 basic questions.
1. I am getting the name of the particular sound file required by reading an external file. I need this sound to play just once and to be totally embedded in the page and invisible. When it needs to sound i want to use something like
document.getElementById('s oundfile') .src = "'sounds/"+thissound+".wav '";
to alter the sound according to the value of 'thissound' retreived. I just can't figure out IE/FF code where the required src can be swapped at will. This must be fully cross-browser compatible.
2. Is there any way to retreive a combination of sound files and play one after the other? eg get a file for sound 'Hello' and then another for 'John' and then play them back to back to create 'Hello John'? Obviously I'm simplifying here but just wondered if possible to do.
Many thx
Firstly, this is for audible alerts so is a valid reason for having sound on a page :)
I have 2 basic questions.
1. I am getting the name of the particular sound file required by reading an external file. I need this sound to play just once and to be totally embedded in the page and invisible. When it needs to sound i want to use something like
document.getElementById('s
to alter the sound according to the value of 'thissound' retreived. I just can't figure out IE/FF code where the required src can be swapped at will. This must be fully cross-browser compatible.
2. Is there any way to retreive a combination of sound files and play one after the other? eg get a file for sound 'Hello' and then another for 'John' and then play them back to back to create 'Hello John'? Obviously I'm simplifying here but just wondered if possible to do.
Many thx
ASKER
Yup - I found that on Google a while back - problem is none of them work satisfactorily, hence the question here.
However it seems it was a mistake in my element IDs not the JS all sorted anyway.
However it seems it was a mistake in my element IDs not the JS all sorted anyway.
ASKER
ok - all sorted - sry :)
Just simply used a timeout before swapping the sound file again. Would be nice to actually timie it to kick in directly after the previous one has ended but is good enough for the purpose.
Just simply used a timeout before swapping the sound file again. Would be nice to actually timie it to kick in directly after the previous one has ended but is good enough for the purpose.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm