Background music script for website

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Enthusiast Hainesy is offline
    MemberRank
    Dec 2008 Join Date
    44Posts

    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

    PHP Code:
    <body
    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.


  2. #2
    may web.very maple.pls. iAkira is offline
    MemberRank
    Aug 2009 Join Date
    somewhere..Location
    2,378Posts

    Re: Background music script for website

    Nice work but i rather have a
    music player that u can stop or play xD

  3. #3
    Enthusiast Hainesy is offline
    MemberRank
    Dec 2008 Join Date
    44Posts

    Re: Background music script for website

    yes i suppose but i thought id release it just in case.

    well, suppose its kinda a guide

  4. #4
    Account Upgraded | Title Enabled! xHerDesire<33 is offline
    MemberRank
    Jul 2009 Join Date
    DunnoLocation
    440Posts

    Re: Background music script for website

    Quote Originally Posted by iAkira View Post
    Nice work but i rather have a
    music player that u can stop or play xD
    Agreed, anyone have a good website for one?

  5. #5
    may web.very maple.pls. iAkira is offline
    MemberRank
    Aug 2009 Join Date
    somewhere..Location
    2,378Posts

    Re: Background music script for website

    mixpod.com

  6. #6
    Account Upgraded | Title Enabled! myangel is offline
    MemberRank
    Apr 2009 Join Date
    EarthLocation
    319Posts

    Re: Background music script for website

    Quote Originally Posted by iAkira View Post
    mixpod.com
    I love you.
    This is a nice website.
    *1 thanks for you.*

  7. #7
    Enthusiast NhatQuang is offline
    MemberRank
    Jun 2008 Join Date
    31Posts

    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
    Last edited by NhatQuang; 11-11-09 at 10:39 PM.

  8. #8
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    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\">"
    }
    ?>
    Last edited by holthelper; 12-11-09 at 02:45 AM.

  9. #9
    Enthusiast NhatQuang is offline
    MemberRank
    Jun 2008 Join Date
    31Posts

    Re: Background music script for website

    Quote Originally Posted by holthelper View Post
    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
    Last edited by NhatQuang; 12-11-09 at 04:31 AM.

  10. #10
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: Background music script for website

    Quote Originally Posted by NhatQuang View Post
    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

  11. #11
    Enthusiast tomxi123 is offline
    MemberRank
    Jul 2008 Join Date
    FinlandLocation
    30Posts

    Re: Background music script for website

    Nice !
    im gonna use

  12. #12
    Proficient Member lit0aznb3ar is offline
    MemberRank
    Jan 2009 Join Date
    151Posts

    Re: Background music script for website

    Quote Originally Posted by holthelper View Post
    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 ^^

  13. #13
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: Background music script for website

    Quote Originally Posted by lit0aznb3ar View Post
    Works like a charm ^^
    your welcome.

    this is an example of coding error. you need to develop something that works across many platform.

  14. #14
    ♥Fatal|Error♥ JungleByte is offline
    MemberRank
    Oct 2009 Join Date
    Singapore, SingLocation
    1,096Posts

    Re: Background music script for website

    Does this works for butsags?

  15. #15
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: Background music script for website

    cool bump bro.

    smart............................. its for the website SO yes IT will WORK for BUTSAGES cms



Page 1 of 2 12 LastLast

Advertisement