Background sound plays once only? Is this possible.

  • Thread starter Kootenay Photography
  • Start date
K

Kootenay Photography

I searched the group but all the info on this is quite old.

Is there a way to have your background sound file play only once?

We have had a professional announcer create an voice over for our site
to recruit potential employees but would rather the sound not play
each time the index page is opened.

Is there a way to set the BG sound to only play once?

you can see what I mean here at http://www.sutco.ca

Thanks
 
R

Rob Giordano [MS MVP]

Add loop="1" to the code, like this (disregard the path to the file below)

<bgsound src="file:///D:/My%20Documents/My%20Music/smoking.wav" loop="1">

Or when inserting the bgsound option in FP's Page Options dialog uncheck
Forever and enter the amt of times you want it to loop.

(PS...the preferred setting is NO bgsound)
 
K

Kootenay Photography

I have it set to only play once, but when the visitor returns to the
INDEX page it plays again when I have that setting.

I set up my menus to go to an identical INDEX2 page with no BG sound
but that is a workaround. I was hoping there was different method.
 
T

Trevor Lawrence

Kootenay Photography said:
I have it set to only play once, but when the visitor returns to the
INDEX page it plays again when I have that setting.

I set up my menus to go to an identical INDEX2 page with no BG sound
but that is a workaround. I was hoping there was different method.

I have set some music on my index page http://tandcl.homemail.com.au/ with a
play button.

So then the choice is up to the viewer, and it only plays once each time

The code (JS) is very simple
function playSound(fname)
{
if (!fname)
fname = "audio/minuet.mid"
var x = document.getElementById("sound")
x.innerHTML = (!x.innerHTML ) ? '<embed src="' + fname + '" loop=false
autostart=true hidden>' : ''
}

It is executed by this HTML
<span id="sound"></span>
<input type="button" value="Play/Stop
Music"
onclick="playSound()" title="Play/Stop Music" />

The file played is audio/minuet.mid
 
R

Ronx

Rob's advice will limit the sound to a single loop whilst the page is
open. To prevent the sound repeating on subsequent returns to the page
you need to use cookies or session variables. Session variables
requires server side coding such as asp, PHP, asp.NET etc., cookies
require JavaScript or server side scripting.

There are articles on using cookies at
http://irt.org/articles/script11.htm, and there is probably a page at
http://www.w3schools.com that will assist - w3schools.com site is down
at the moment (07:50GMT)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top