kargrafx
07-05-2004, 09:11 AM
Okay, I have a simple request, I think. I have a simple code to play wav files on my site, and I have it working with multiple occurences of the code so that for each wav file you see the player. However, not only is this cluttered, but it allows for multiple wav's to be playing at once which sounds bad. So instead of 12 player bars, I want to change to a drop down menu to select the wav, and then have a single player bar below the menu to play the currently selected track.
the code I currently have is this:<script language="JavaScript"><!--
if(navigator.plugins.length>0){
if (navigator.mimeTypes["audio/wav"] && navigator.mimeTypes["audio/wav"].enabledPlugin) document.write('<embed src="track01.wav" autostart="false" loop="0" controls="LargeConsole" width=180 height=35></embed>');}
else {
document.write('<embed src="track01.wav" autostart="false" loop="0" width=180 height=45></embed>');}
//-->
</script>
Of course it is repeated for each track, with the source wav file changed. I would like to instead replace it with something like this;<script language="JavaScript"><!--
if(navigator.plugins.length>0){
if (navigator.mimeTypes["audio/wav"] && navigator.mimeTypes["audio/wav"].enabledPlugin) document.write('<embed src="'+soundFile+'" autostart="false" loop="0" controls="LargeConsole" width=180 height=35></embed>');}
else {
document.write('<embed src="'+soundFile+'" autostart="false" loop="0" width=180 height=45></embed>');}
//-->
</script>Of course with this method, I have to set var soundFile somehow - and I would like to do it with a drop down menu; but I have never done that so would like suggestions on how to...
Here is a list of what I would like to happen in the finished product: a drop-down menu has a list of tracks. Below it is the player bar to listen to the currently selected track. Whenever the 'play' button is pressed, it plays the track currently displayed in the drop-down menu; however if the menu is changed while playing, I don't want it to stop the music playing, nor change the music playing... only change the variable so that if the user stops the track, or lets it end, and then presses play again, the new choice is played.
I'm not sure if I said that clearly enough; I am a bit tired...but anyway;
Thanks for your help!
the code I currently have is this:<script language="JavaScript"><!--
if(navigator.plugins.length>0){
if (navigator.mimeTypes["audio/wav"] && navigator.mimeTypes["audio/wav"].enabledPlugin) document.write('<embed src="track01.wav" autostart="false" loop="0" controls="LargeConsole" width=180 height=35></embed>');}
else {
document.write('<embed src="track01.wav" autostart="false" loop="0" width=180 height=45></embed>');}
//-->
</script>
Of course it is repeated for each track, with the source wav file changed. I would like to instead replace it with something like this;<script language="JavaScript"><!--
if(navigator.plugins.length>0){
if (navigator.mimeTypes["audio/wav"] && navigator.mimeTypes["audio/wav"].enabledPlugin) document.write('<embed src="'+soundFile+'" autostart="false" loop="0" controls="LargeConsole" width=180 height=35></embed>');}
else {
document.write('<embed src="'+soundFile+'" autostart="false" loop="0" width=180 height=45></embed>');}
//-->
</script>Of course with this method, I have to set var soundFile somehow - and I would like to do it with a drop down menu; but I have never done that so would like suggestions on how to...
Here is a list of what I would like to happen in the finished product: a drop-down menu has a list of tracks. Below it is the player bar to listen to the currently selected track. Whenever the 'play' button is pressed, it plays the track currently displayed in the drop-down menu; however if the menu is changed while playing, I don't want it to stop the music playing, nor change the music playing... only change the variable so that if the user stops the track, or lets it end, and then presses play again, the new choice is played.
I'm not sure if I said that clearly enough; I am a bit tired...but anyway;
Thanks for your help!