Background music script for website
Ok, ive been seeing a few requests for a background music script for their CMS. I did put one into the phoenixms cype but i thought id release it here.
PHP Code:
<php
if(rand(0,3)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\bluesky.mp3" loop="infinite">';
}
elseif(rand(0,2)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\amoria.mp3" loop="infinite">';
}
elseif(rand(0,1)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\shiningharbor.mp3" loop="infinite">';
} else{
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\upon the sky.mp3" loop="infinite">';
}
?>
now you must be thinking, where do i put it?
my advice is to put it into header.php
ok now you have header.php open you need to search for
which is the start of the main part of your website.
once you have found that add the code in above it so it looks like this :
PHP Code:
<php
if(rand(0,3)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\bluesky.mp3" loop="infinite">';
}
elseif(rand(0,2)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\amoria.mp3" loop="infinite">';
}
elseif(rand(0,1)==0) {
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\shiningharbor.mp3" loop="infinite">';
} else{
echo '
<bgsound src="C:\wamp\www\site\sources\bgm\upon the sky.mp3" loop="infinite">';
}
?>
<body>
now youve done the code you need some music.
as you can see in the code there are file directories pointing to the mp3. Make a folder somewhere in your websites files, put your mp3's inside and change the directories in the script to point to your mp3.
I hope this has helped.
Re: Background music script for website
Nice work but i rather have a
music player that u can stop or play xD
Re: Background music script for website
yes i suppose but i thought id release it just in case.
well, suppose its kinda a guide
Re: Background music script for website
Quote:
Originally Posted by
iAkira
Nice work but i rather have a
music player that u can stop or play xD
Agreed, anyone have a good website for one?
Re: Background music script for website
Re: Background music script for website
Quote:
Originally Posted by
iAkira
mixpod.com
I love you.
This is a nice website.
*1 thanks for you.* :drool:
Re: Background music script for website
it doesnt work?......nothing happens after i added that....no music at all and there are mp3 files in the bgm folder...im sure of that
Re: Background music script for website
1) doesnt work because the link is messed up.
2) the code is ugly
here...
PHP Code:
<?php
$random = rand(0,3);
if($random == 3) {
echo "<bgsound src=\"./sources/bgm/bluesky.mp3\" loop=\"infinite\">";
} elseif($random == 2) {
echo "<bgsound src=\"./sources/bgm/amoria.mp3\" loop=\"infinite\">";
} elseif($random == 1) {
echo "<bgsound src=\"./sources/bgm/shiningharbor.mp3\" loop=\"infinite\">";
} else {
echo "<bgsound src=\"./sources/bgm/upon the sky.mp3\" loop=\"infinite\">";
}
?>
Re: Background music script for website
Quote:
Originally Posted by
holthelper
1) doesnt work because the link is messed up.
2) the code is ugly
here...
PHP Code:
<?php
$random = rand(0,3);
if($random == 3) {
echo "<bgsound src=\"./sources/bgm/bluesky.mp3\" loop=\"infinite\">";
} elseif($random == 2) {
echo "<bgsound src=\"./sources/bgm/amoria.mp3\" loop=\"infinite\">";
} elseif($random == 1) {
echo "<bgsound src=\"./sources/bgm/shiningharbor.mp3\" loop=\"infinite\">";
} else {
echo "<bgsound src=\"./sources/bgm/upon the sky.mp3\" loop=\"infinite\">";
}
?>
ok i put that and nothing happens o.O i went to my website's homepage and no music at all......
EDIT: it works but only on internet explorer...not on the other browsers such as chrome and firefox
Re: Background music script for website
Quote:
Originally Posted by
NhatQuang
ok i put that and nothing happens o.O i went to my website's homepage and no music at all......
EDIT: it works but only on internet explorer...not on the other browsers such as chrome and firefox
PHP Code:
<?php
$random = rand(0,3);
$browser = $_SERVER['HTTP_USER_AGENT'];
if((strpos($browser, "Firefox") !=0) || (strpos($browser, "Chrome") !=0)) {
if($random == 3) {
echo "<embed src=\"./sources/bgm/bluesky.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} elseif($random == 2) {
echo "<embed src=\"./sources/bgm/amoria.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} elseif($random == 1) {
echo "<embed src=\"./sources/bgm/shiningharbor.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} else {
echo "<embed src=\"./sources/bgm/upon the sky.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
}
} else {
if($random == 3) {
echo "<noembed><bgsound src=\"./sources/bgm/bluesky.mp3\" loop=\"infinite\"></noembed>";
} elseif($random == 2) {
echo "<noembed><bgsound src=\"./sources/bgm/amoria.mp3\" loop=\"infinite\"></noembed>";
} elseif($random == 1) {
echo "<noembed><bgsound src=\"./sources/bgm/shiningharbor.mp3\" loop=\"infinite\"></noembed>";
} else {
echo "<noembed><bgsound src=\"./sources/bgm/upon the sky.mp3\" loop=\"infinite\"></noembed>";
}
}
?>
should work for all firefox, chrome, and iexplorer.exe
Re: Background music script for website
Re: Background music script for website
Quote:
Originally Posted by
holthelper
PHP Code:
<?php
$random = rand(0,3);
$browser = $_SERVER['HTTP_USER_AGENT'];
if((strpos($browser, "Firefox") !=0) || (strpos($browser, "Chrome") !=0)) {
if($random == 3) {
echo "<embed src=\"./sources/bgm/bluesky.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} elseif($random == 2) {
echo "<embed src=\"./sources/bgm/amoria.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} elseif($random == 1) {
echo "<embed src=\"./sources/bgm/shiningharbor.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
} else {
echo "<embed src=\"./sources/bgm/upon the sky.mp3\" autostart=\"true\" loop=\"true\" width=\"2\" height=\"0\"></embed>";
}
} else {
if($random == 3) {
echo "<noembed><bgsound src=\"./sources/bgm/bluesky.mp3\" loop=\"infinite\"></noembed>";
} elseif($random == 2) {
echo "<noembed><bgsound src=\"./sources/bgm/amoria.mp3\" loop=\"infinite\"></noembed>";
} elseif($random == 1) {
echo "<noembed><bgsound src=\"./sources/bgm/shiningharbor.mp3\" loop=\"infinite\"></noembed>";
} else {
echo "<noembed><bgsound src=\"./sources/bgm/upon the sky.mp3\" loop=\"infinite\"></noembed>";
}
}
?>
should work for all firefox, chrome, and iexplorer.exe
Works like a charm ^^
Re: Background music script for website
Quote:
Originally Posted by
lit0aznb3ar
Works like a charm ^^
your welcome.
this is an example of coding error. you need to develop something that works across many platform.
Re: Background music script for website
Does this works for butsags?
Re: Background music script for website
cool bump bro.
smart............................. its for the website SO yes IT will WORK for BUTSAGES cms