Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stream MP3 in the background

Posted on 2004-08-19
3
Medium Priority
?
246 Views
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.
0
Comment
Question by:peledc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

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

<script language="javascript">

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

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
music[1]="mymusic1.mp3";
music[2]="mymusic2.mp3";
music[3]="mymusic3.mp3";
music[4]="mymusic4.mp3";
music[5]="mymusic5.mp3";
music[6]="mymusic6.mp3";
music[7]="mymusic7.mp3";
music[8]="mymusic8.mp3";
music[9]="mymusic9.mp3";

i=rand(9);

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> ')
   }
}
</script>

Add this code after tha <BODY> tag

<script>music();</script>

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

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

/squew/
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
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…

721 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