You are here: Random BGSOUND script « All PHP « IT news, forums, messages
Random BGSOUND script

Posted by Fred Atkinson on 09/29/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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация