Stream MP3 in the background

Posted on 2004-08-19
Last Modified: 2013-12-24
As a newbee,
I am looking for a way to stream background sound in my website.
I have 10 different themes, currently in MP3.

1. A theme would be chosen randomly and played in the background.
2. Each sound file is like 3MB and therefore better not force the users to download all of them
   in advance.
3. I would like to give the user the ability to change the background music.
Question by:peledc

Accepted Solution

Squew01 earned 500 total points
ID: 11860244
Add this script just after the <HEAD> tag

<script language="javascript"> Date();;

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);

function rand(number) {
        return Math.ceil(rnd()*number);

function music()
music[0]="mymusic0.mp3"; // Don't forget to change the name


if (navigator.appName.indexOf("Microsoft") != -1){        
document.write('<BGSOUND SRC="'+ music[i] +'"> ')    
else if (navigator.appName.indexOf("Netscape") != -1){
document.write('<EMBED SRC="'+ music[i] +'" HIDDEN=TRUE AUTOSTART=TRUE> ')

Add this code after tha <BODY> tag


To change the played song, use this link <A href="#">Another Song</a>

Don't forget to change mymusic0.mp3, mymusic1.mp3, ...


Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Web Developer 7 272
Code Editors 10 211
HTML Editor That Indents Code As Illustrated 11 138
Why is this simple, masked Flash animation flickering? 20 193
Now that Expression Web 4.0 ( is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Go t…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question