• 0

Background Audio on website


Question

3 answers to this question

Recommended Posts

  • 0

you can use <bgsound loop=true src="file.mp3">

or <embed name="file" src ="file.mp3" loop=true autostart=false hidden=true mastersound>

OR you can combine both, and use a script to switch between the files.

here's an example :

<body>

<bgsound id="silence" loop=1 src="silence.mp3">

<embed name="Song1" src="Song1.mp3" loop=false autostart=false hidden=true mastersound>

<embed name="Song2" src="Song2.mp3" loop=false autostart=false hidden=true mastersound>

<script language="JavaScript">

ver=parseInt(navigator.appVersion)

ie4=(ver>3 && navigator.appName!="Netscape")?1:0

ns4=(ver>3 && navigator.appName=="Netscape")?1:0

ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playsong1(){

if (ie4) document.all['BGSOUND_ID'].src='Song1.mp3';

if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi'] && self.document.Song1.IsReady()){

self.document.Song1.play()

}}

function playsong2(){

if (ie4) document.all['BGSOUND_ID'].src='Song2.mp3';

if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi'] && self.document.Song2.IsReady()){

self.document.Song2.play()

}}

</script>

and then, in an object, simply include the function call for an event. for example :

<a onClick=playsong1()>SONG1</a>

Hope this helps and is clear enough

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.