I have a mp3 player source code and i made it work with play, pause, next and previous buttons including volume controller. now i need to add shuffle also to it.
can someone help me?
here is the code. or else someone can give me a flash player with shuffle function and it should be customizable. using xml.
Flash Code:
function adjustVolume()
{
var __reg1 = volume_mc.slider_mc._x * 2;
jukebox.setVolume(__reg1);
}
function nextSong()
{
if (songArray[currentIndex + 1])
{
++currentIndex;
}
else
{
currentIndex = 0;
}
jukebox.loadSound(urls[currentIndex],true);
title_txt.text = titles[currentIndex];
paused = false;
}
function prevSong()
{
if (currentIndex > 0)
{
–currentIndex;
}
else
{
currentIndex = songArray.length - 1;
}
jukebox.loadSound(urls[currentIndex], true);
title_txt.text = titles[currentIndex];
paused = false;
}
var jbx = new XML();
jbx.ignoreWhite = true;
var songArray = new Array();
var urls = new Array();
var titles = new Array();
var artists = new Array();
var currentIndex = 0;
var volumeInterval;
var jukebox = new Sound();
volume_mc.slider_mc.onPress = function ()
{
startDrag(this, 0, 0, 0, 50, 0);
volumeInterval = setInterval(adjustVolume, 50);
}
;
volume_mc.slider_mc.onRelease = volume_mc.slider_mc.onReleaseOutside = function ()
{
stopDrag();
}
;
jbx.onLoad = function (success)
{
if (success)
{
songArray = jbx.firstChild.childNodes;
i = 0;
while (i < songArray.length)
{
urls.push(songArray*.attributes.url);
titles.push(songArray*.attributes.title);
artists.push(songArray*.attributes.artist);
++i;
}
jukebox.loadSound(urls[currentIndex], true);
title_txt.text = titles[currentIndex];
artist_txt.text = artists[currentIndex];
return;
}
title_txt.text = "Out of Order. Try again later.";
}
;
jbx.load(“jukebox.xml”);
var currentPosition = 0;
var paused = false;
stop_btn.onRelease = function ()
{
currentPosition = 0;
jukebox.stop();
paused = true;
}
;
play_btn.onRelease = function ()
{
if (paused)
{
jukebox.start(currentPosition);
paused = false;
}
}
;
pause_btn.onRelease = function ()
{
if (!paused)
{
currentPosition = jukebox.position / 1000;
jukebox.stop();
paused = true;
return;
}
if (currentPosition > 0)
{
jukebox.start(currentPosition);
paused = false;
}
}
;
mute_btn.onRelease = function ()
{
if (jukebox.getVolume() > 0)
{
jukebox.setVolume(0);
return;
}
jukebox.setVolume(100);
}
;
next_btn.onRelease = nextSong;
prev_btn.onRelease = prevSong;
jukebox.onSoundComplete = nextSong;
sof_mc.invisible_btn.onRelease = function ()
{
ad_mc.play();
}
;
xml code:
<?xml version=“1.0” encoding=“ISO-8859-1”?>
<jukebox>
<song title=" " artist=" " url=“radio/19.mp3” />
<song title=" " artist=" " url=“radio/20.mp3” />
</jukebox>