...

View Full Version : Using a javascript mp3 player, is it possible to get the script to play random files?



twwn
02-19-2007, 03:55 PM
Using a javascript mp3 player, is it possible to get the script to play random mp3 files out of a designated foler? For example, if I have a folder named "music" and I want the script to open up the folder and select a random file for playback, is this even possible? Is there some code I can add to the script that will make this work? This si the code for the entire webpage...

-----------------------------------------------------------
<head>
<title>radio</title>

<link rel="stylesheet" type="text/css" href="lb_JSPlayer.css" />

<script type="text/javascript" src="cookies.js"></script>
<script type="text/javascript" src="lb_common.js"></script>
<script type="text/javascript" src="lb_html.js"></script>

<script type="text/javascript" src="lb_menu.js"></script>
<script type="text/javascript" src="lb_JSPlayer_core.js"></script>
<script type="text/javascript" src="lb_JSPlayer.js"></script>
</head>
<body>

<script language="Javascript">
new clb_JSPlayer("***filelink****", "QTP", "****filelink****");
</script>

</body>

-----------------------------------------------------------

The page can be viewed at http://www.twwn.net/radio/radio.php

Philip M
02-20-2007, 07:49 AM
Try this:-



<SCRIPT type= "text/javascript">
// var numsongs stands for the number of songs given
var numsongs = 5 // replace with any number you want
day = new Date()
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*numsongs
+ 1,10)

if (ran == (5))
{
song =("insert file src here")
words =("input song title here")
}
else if (ran == (4))
{
song =("insert file src here")
words =("input song title here")
}
else if (ran == (3))
{
song =("insert file src here")
words =("input song title here")
}
else if (ran == (2))
{
song =("insert file src here")
words =("input song title here")
}
else if (ran == (1))
{
song =("insert file src here")
words =("input song title here")
}

document.write('<EMBED SRC= "' + song + '" CONTROLS=smallconsole HEIGHT=45 WIDTH=290 AUTOSTART=TRUE LOOP=TRUE VOLUME=35%>')
document.write('<br>You are listening to ' + words + ' ')
</SCRIPT>

tonyp12
02-20-2007, 02:44 PM
But you want to just point to a folder and have it open it and
read all mp3 files in there by itself and random play one.

could be done, but
var fso=new ActiveXObject("Scripting.FileSystemObject");

Creates warnings, unless run localaly and renamed .hta



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum