Ok, well, here goes...
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
_global.songinfo = [];
_global.songurl = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
_global.songinfo[i] = playlist.firstChild.childNodes[i].attributes.info;
// add the following line
_global.songurl[i] = playlist.firstChild.childNodes[i].attributes.url;
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_global.song_nr = random(songfile.length);
// modify the following line
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songinfo[song_nr], songurl[song_nr]);
};
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? "0"+min : min;
sec = Math.floor(time%60);
sec = (sec<10) ? "0"+sec : sec;
timeDisplay_txt.text = min+":"+sec+"/"+totalDuration;
}
function duration (){
timed = _root.sound_mc.sound_obj.duration/1000;
mind = Math.floor(timed/60);
mind = (mind<10) ? "0"+mind : mind;
secd = Math.floor(timed%60);
secd = (secd<10) ? "0"+secd : secd;
totalDuration = mind+":"+secd;
}
// modify the following line
MovieClip.prototype.songStarter = function(file, name, band, info, url) {
if (this.sound_obj) {
this.sound_obj.stop();
delete this.sound_obj;
}
this.sound_obj = new Sound(this);
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
display_txt.htmlText = name+" / "+band;
info_mc.info_text.html = true; // add this line
info_mc.info_text.htmlText = "<a href = \"" + url + "\" target =\"_blank\">" + info + "<a/>"; // modify this line
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
display_txt.text = "loading...";
info_mc.info_text.text = "loading...";
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
timeDisplay_txt.text = "";
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songinfo[song_nr], songurl[song_nr]);
};
this.sound_obj.setVolume(50);
};
btn_play.onRelease = function() {
if (pause = true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
timeDisplay_txt.text = "";
this._parent.sound_mc.songStarter(songfile[song_nr]);
}
};
btn_pause.onRelease = function() { //pause button function
this._parent.sound_mc.sound_obj.stop(); //stop the current sound
posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec)
pause = true;//set the variable pause to true
}
btn_fw.onRelease = function() {
clearInterval(timeInterval);
timeDisplay_txt.text = "";
var tempHolder = _global.song_nr
_global.song_nr = random(songfile.length);
if(tempHolder == _global.song_nr ){
_global.song_nr = random(songfile.length);
}
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songinfo[song_nr], songurl[song_nr]);
};
btn_rev.onRelease = function() {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "";
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songinfo[song_nr], songurl[song_nr]);
};
playlist.load("full-playlist.xml");
setInterval(duration,100);
So I guess, taking that code, I want to do this:
* New XML
* List attributes
* Create empty MC (sound_mc)
* Set randomize (although I must admit I don't understand how random(songfile.length) works - does it randomize based on the length of the song??
* Read each played song into an array
* start sound_mc (I think)
* do timer function (don't think we need to change that, as it's just telling the time display what to display, right?)
* do duration function (same thing, I guess?)
* Guessing here, but maybe modify the onSoundComplete function to check the array?
* Not sure we need to modify the play button
* Not sure we need to modify the pause button
* Modify the next button to check the array before choosing an unplayed song randomly
* Modify the prev button to check what the previous song in the array was, and play it
* Load playlist
* Set interval for duration code
* I'm also thinking there's extra modification needed for when ALL songs have been played into the array - probably an if statement?
There you go - probably embarassed myself badly with those uneducated guesses, but hopefully you'll forgive me
...and as if I haven't given you enough to do, it would be lovely if you could take a look at my asfunction post, as it and this are the only things I need to address before launching the new site
Thank you very much for all your help, mate - literally couldn't have done it without you!!!!
Edited by boogooloo1, 09 April 2007 - 03:15 AM.