|
Posted by Fred Atkinson on 10/15/73 12:00
I've written a PHP script that randomly selects a sound file
to play for the BGSOUND tag. It appears below. All you have to do is
place it between the <head> and </head> tags on a PHP Web page.
<?php
$array = array("sound_1.wav",
"sound_2.wav",
"sound_3.wav");
$n = rand (0, 2);
$sound_file = $array[$n];
echo "<bgsound src=\"$sound_file\">\n"
?>
The problem is that when I test it, it seems to favor the
first and the last sound file and rarely plays the second one.
Is there a better way to make the random number selection more
evenly distributed?
Before you start jumping on me about music in the background,
that's not what I am doing. Go to http://www.wb4aej.com for a working
example. I've got a test page (with a refresh button) on
http://www.wb4aej.com/random_wav.php . If you don't copy Morse code,
you probably won't understand the different sounds except that the
first few characters of each sound file are a little different. Each
file plays for only a few seconds and stops.
I've also added links to the test page so you can play the
random files individually.
Regards,
Fred
[Back to original message]
|