Click to See Complete Forum and Search --> : Complete code needed for playing and stop playing a sound file


griis
09-20-2003, 05:19 PM
I want to play a mp3 sound file (that is in my homepage directory) by clicking the word: "Start", and to stop the same sound from playing by clicking the word: "Stop", how am I to do that? I don't want the mediaplayer it self to appear while playing, just to hear the sound. I have no knowledge about java and html coding at all. I'll be very grateful, if any of you could please write and send the entire code I am to put in my page to make this work. And also to tell me, where in the page I am to add the code. Thank you very much! Jette. griis@paaruplund.dk :confused:

spykemitchell
09-20-2003, 05:53 PM
Ah this one is easy. At the bottom of your page (after all the text etc.. put the following,

<iframe src="blank.htm" width="0.1" height="0.1" name="music"></iframe>

Then create an html document called blank.htm with the same Background colour as your page and put ti in the same directory as your page with the iframe in it.

Then create a page for each of your sounds called sound1.htm, sound2.htm exactly the same as blank.htm with the following tag in each

<bgsound src="name of song.mp3" loop="infinite">

Then on the site you have your i frame in put,

<a href="sound1.htm" target="music">start</a><a href="blank.htm" target="music">Stop</a>

This is a really basic way of doing it but never the less it is an way of doing it.

The only problem is that some peoples browsers don't support frames therefore it wont work. Your best bet is PHP which Pyro can tell you all about!

Spyke.

spykemitchell
09-20-2003, 05:53 PM
Ah this one is easy. At the bottom of your page (after all the text etc.. put the following,

<iframe src="blank.htm" width="0.1" height="0.1" name="music"></iframe>

Then create an html document called blank.htm with the same Background colour as your page and put ti in the same directory as your page with the iframe in it.

Then create a page for each of your sounds called sound1.htm, sound2.htm exactly the same as blank.htm with the following tag in each

<bgsound src="name of song.mp3" loop="infinite">

Then on the site you have your i frame in put,

<a href="sound1.htm" target="music">start</a><a href="blank.htm" target="music">Stop</a>

This is a really basic way of doing it but never the less it is an way of doing it.

The only problem is that some peoples browsers don't support frames therefore it wont work. Your best bet is PHP which Pyro can tell you all about!

Spyke.

S1L3NC3
09-20-2003, 05:55 PM
Just a suggestion to people with more knowledge than I, but could you do something like this?:

(note: This syntax is more than likely not correct as i have no idea if this can even be done, its just a suggestive idea to help someone smarter than me solve this problem.)


<input type="submit" value="Play" name="mPlay" onClick="(document.bgsound src="songname here" loop="infinite")">

<input type="submit" value="Stop" name="mStop" onClick="(document.bgsound src="")">