...

View Full Version : Need help tweaking music player code



rocketfoot
12-07-2010, 07:30 PM
I hope someone can help me...I need to tweak this code so that background music will play randomly for an unlimited time. Right now, it plays a random song and then repeats it over and over. I just need to have it randomly change songs and keep playing! Here is the code I am using...



<script type="text/javascript">

var musicSource = [
"http://www.bigmacktrucks.com/music/1.mp3",
"http://www.bigmacktrucks.com/music/2.mp3",
"http://www.bigmacktrucks.com/music/3.mp3",
"http://www.bigmacktrucks.com/music/4.mp3",
"http://www.bigmacktrucks.com/music/5.mp3",
"http://www.bigmacktrucks.com/music/6.mp3",
"http://www.bigmacktrucks.com/music/7.mp3",
"http://www.bigmacktrucks.com/music/8.mp3"
];

var rand = Math.floor(Math.random()*musicSource.length);
document.write('<embed src="'+musicSource[rand]+'" autoplay="true" hidden="true" loop="true" />');

// -->
</script>

I think this is simple but I am a total noob at javascript! Thanks in advance!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum