Click to See Complete Forum and Search --> : Reference this script within an Iframe...


Code One
06-17-2003, 01:16 AM
Hello,
I am trying to make a wav player and what I got so far is how to select an embed src, have it saved in a string, and then played when I click the play button. Now here is what I would really like to happen.

I would like for this page - (Help!.htm):
===================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Help me!</title>

<script language="JavaScript">
var playlist = new Array();
var x = -1;

function add(sound){
x=x+1;
playlist[x] = sound;
}//ends add()

function play_it(){
for (i = 0; i < playlist.length; i++){
document[playlist[i]].Play();
}//ends FOR
}//ends play_it()
</script>
</head>

<body>
<a href="javascript: add('a')">Music1</a><br><br>

<a href="javascript: add('b')">Music2</a><br><br>

<a href="javascript: add('c')">Music3</a><br><br>

<form>
<input type="button" value="Play" onClick="play_it()">

<input type="button" value="Reset" onClick="history.go()">
</form>

<!-- Sound Embeds -->
<embed name="a" src="Music1.wav" autostart="false" hidden="true" loop="false"></embed>

<embed name="b" src="Music2.wav" autostart="false" hidden="true" loop="false"></embed>

<embed name="c" src="Music3" autostart="false" hidden="true" loop="false"></embed>

</body>
</html>
========================================================

to be referenced and fired in another page - (I'm helped.htm):

========================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Help me!</title>

<script language="JavaScript">
function ???????(){
????????????????
</script>
</head>

<body>
<Iframe src="Help me!.htm" width=100 height=100>

<input type="button" onClick="??????()">
</body>
</html>
=========================================================

so that the sound files embeded in the "Help me!.htm" page will be saved in a string somewhere and can be fired and played in the "I'm helped.htm" page.

Any help is appreciated,

Code One

SlankenOgen
06-17-2003, 06:03 AM
What you have to do is create an array of music titles

var M = new Array("Music1.wav","Music2.wav",...);

var played = new Array();

var lgn = M.length;

var counter = 0;

for(var i = 0; i < lgn; i++)
{
played[i] = -1;
}

function storeTrack(n)
{
played[counter++] = n;
}

Then to replay a track - M[played[x]]

Then for the links

<a href="Music1.wav" onclick = "storeTrack(0)">Music1</a>
<a href="Music2.wav" onclick = "storeTrack(1)">Music2</a>
.
.
.

That's a brief sketch but the rest should be easy.

~mgb

Code One
06-17-2003, 02:08 PM
thanks alot for answering this post. All though your answer was not what I was looking for I still am appreciative towards you for trying.


thanks alot,

Code One

gsb
06-17-2003, 02:31 PM
How many sounds will you need, and how big are the files.
I ask for there is a way to create one object with all your sounds and play them as needed via JavaScript.

If al lot of seldom used .wav and they are large this might not be the best way. I have a sample somewhere I can post for you later.

Code One
06-17-2003, 09:18 PM
Lets say 10 sounds I can use mp3 so approx. 1mb each (?). I would love to see your sample If I could. Please post it.

Thanks,

Code One

gsb
06-17-2003, 09:52 PM
Well, lets try this again. The board did not like the zip attachment.

As I was saying...

Your OP stated .wav files. I was thinking like:
"Thank you", "E-mail not registered", "Need help", etc..

Anyway, I used a program called SWiSH, a poor man's (woman's) Flash. BTW its free (trial, all you need) and simple with attached example. To play a sound something like this:
onClick="return sound('chimes')"
...or in the case of an iFrame
onClick="return parent.sound('chimes')."

Anyway, an example:
sounds example (http://www.GypsyTrader.com/temp/sounds_test.html)
and the zip:
sounds.zip (http://www.GypsyTrader.com/temp/sounds.zip)

Hope it helps.
gsb

Code One
06-17-2003, 10:24 PM
you cheated, swish is easy. In order to execute what Im trying to do I do have to make the whole page in flash and I really dont feel like it. It just is to boring to me. Thanks for the help though.

Code One

gsb
06-17-2003, 10:41 PM
Wait a minute.

I thought you needed a way to play the sounds on demand via JavaScript.
No big page required, just sound files (.wav) one after another in one .swf.
Play each independently from JavaScript.

Easy solution.

Sorry I missed your point.

gsb :(