Complete code needed for playing and stop playing a sound file

admin

Administrator
Staff member
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. <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> :confused:<!--content-->Ah this one is easy. At the bottom of your page (after all the text etc.. put the following,<br />
<br />
<iframe src=http://www.webdeveloper.com/forum/archive/index.php/"blank.htm" width="0.1" height="0.1" name="music"></iframe><br />
<br />
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.<br />
<br />
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<br />
<br />
<bgsound src=http://www.webdeveloper.com/forum/archive/index.php/"name of song.mp3" loop="infinite"><br />
<br />
Then on the site you have your i frame in put,<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"sound1.htm" target="music">start</a><a href="blank.htm" target="music">Stop</a><br />
<br />
This is a really basic way of doing it but never the less it is an way of doing it.<br />
<br />
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!<br />
<br />
Spyke.<!--content-->Ah this one is easy. At the bottom of your page (after all the text etc.. put the following,<br />
<br />
<iframe src=http://www.webdeveloper.com/forum/archive/index.php/"blank.htm" width="0.1" height="0.1" name="music"></iframe><br />
<br />
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.<br />
<br />
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<br />
<br />
<bgsound src=http://www.webdeveloper.com/forum/archive/index.php/"name of song.mp3" loop="infinite"><br />
<br />
Then on the site you have your i frame in put,<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"sound1.htm" target="music">start</a><a href="blank.htm" target="music">Stop</a><br />
<br />
This is a really basic way of doing it but never the less it is an way of doing it.<br />
<br />
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!<br />
<br />
Spyke.<!--content-->Just a suggestion to people with more knowledge than I, but could you do something like this?:<br />
<br />
(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.)<br />
<br />
<br />
<input type="submit" value="Play" name="mPlay" onClick="(document.bgsound src=http://www.webdeveloper.com/forum/archive/index.php/"songname here" loop="infinite")"><br />
<br />
<input type="submit" value="Stop" name="mStop" onClick="(document.bgsound src=http://www.webdeveloper.com/forum/archive/index.php/"")"><!--content-->
 
Back
Top