but1.sym = "play";
but2.sym = "stop";
but3.sym = "rew";
but4.sym = "ffwd";
var song = new Array();
var loaded = 0;
var amt = 0;
var current = 0;
var isplaying = true;
// true = Automatisch starten, false = nicht starten!
var xm = new XML();
xm.ignoreWhite = true;
xm.onLoad = function() {
parse(this);
};
xm.load("playlist.xml");
function parse(obj) {
amt = obj.childNodes.length;
for (var i = 0; i<obj.childNodes.length; i++) {
song[i] = ct.createEmptyMovieClip("song"+i, i);
song[i].src = obj.childNodes[i].attributes.src;
song[i].title = obj.childNodes[i].attributes.title;
song[i].snd = new Sound(song[i]);
song[i].snd.onSoundComplete = function() {
if (isplaying) {
this.start();
}
};
song[i].snd.onLoad = function() {
nextOne();
};
song[i].snd.loadSound(song[i].src, false);
}
}
function nextOne() {
loaded++;
display.text = "loaded "+loaded+" von "+amt;
if (loaded>=song.length) {
init(0);
}
}
function init(n) {
display.text = (n+1)+" von "+song.length+": "+song[n].title;
if (isplaying) {
playSound();
}
}
function playSound() {
isplaying = true;
song[current].snd.start();
}
function stopSound() {
isplaying = false;
song[current].snd.stop();
}
function switchSound(d) {
song[current].snd.stop();
current += d;
if (current<0) {
current = song.length-1;
}
if (current>song.length-1) {
current = 0;
}
init(current);
}