Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-28-2004, 02:51 PM   #1
purplefish32
Registered User
 
Join Date: Jul 2003
Posts: 16
Default flashamp

i downloaded an xml driven mp3 player from somewhere on actionscrips.org that i unfortunatly cant remember at the moment, (flashamp) annyway killer little app, perfect for what i need, except that i would like to make it autoplay the first song when it is loaded... i just cant seem to get it to do so.
here is the main code :


// Load the song list available on the server
MovieClip.prototype.loadSongList = function(URL) {
// create new XML
this.mySongList = new XML();
this.mySongList.ignoreWhite = true;
this.mySongList.load(URL);
// init the preLoader
// startPreload("_root");
// callback function creates a playlist
this.mySongList.myClip = this;
// onLoad is referenced to the XML so first create a reference to self
this.mySongList.onLoad = function() {
// this now refers to the XML and myClip is used to pass the movieclip reference
//trace(this.myClip);
this.myClip.makePlayList(this);
};
};
//
// make a songlist
MovieClip.prototype.makePlayList = function(myPlayListXML) {
// Hardwired XML reader to read the XML playlist.
// First get the number of songs
this.songNos = myPlayListXML.firstChild.firstChild.childNodes.len gth;
//trace("Number of songs = "+this.songNos);
// create playlist object
this.PlayList = {};
// new object created
this.PlayList.Songs = new Array();
// new array created in the songs object
// songlist is xml with only songs
this.songList = new XML();
this.songList = myPlayListXML.firstChild.firstChild;
this.mySong = this.songList.firstChild;
// trace (mySong);
// trace (songList);
for (var i = 0; i<this.songNos; i++) {
// PlayList.Songs[i] = "Song" + i;
this.PlayList.Songs["name"+i] = this.mySong.firstChild.firstChild.nodeValue;
this.PlayList.Songs["src"+i] = this.mySong.firstChild.nextSibling.firstChild.node Value;
this.PlayList.Songs["artist"+i] = this.mySong.firstChild.nextSibling.nextSibling.fir stChild.nodeValue;
this.mySong = this.mySong.nextSibling;
//trace("song name "+i+" = "+this.PlayList.Songs["name"+i]);
//trace("song src "+i+" = "+this.PlayList.Songs["src"+i]);
//trace("song artist "+i+" = "+this.PlayList.Songs["artist"+i]);
}
this.displayPlayList();
};
// Display songlist
MovieClip.prototype.displayPlayList = function(myPlayListObj) {
myDisplay = "";
for (i=0; i<this.songNos; i++) {
if (i == this.currentSong) {
myColor = "#993300";
} else {
myColor = "#556682";
}
var myArtistName = this.PlayList.Songs["artist"+i];
var mySongName = this.PlayList.Songs["name"+i];
// var displayLength = 15
// if (myArtistName.length >= displayLength){
// myArtistName = myArtistName.substring(0, displayLength);
// }else{
// for (var j=0; i< (displayLength-myArtistName.length); j++){
// myArtistName += " ";
// }
// }
myArtistName += " - ";
// if (mySongName.length >= displayLength){
// mySongName = mySongName.substring(0, displayLength);
// }else{
// for (var j=0; i< (displayLength-mySongName.length); j++){
// mySongName += " ";
// }
// }
mySongName += "";
if (i<9) {
myDisplay += "<font color=\""+myColor+"\"><a href=\"asfunctionlaySong,"+i+"\">"+myArtistName+ " "+mySongName+"</a></font><br>";
} else if (i<99) {
myDisplay += "<font color=\""+myColor+"\"><a href=\"asfunctionlaySong,"+i+"\">"+myArtistName+ " "+mySongName+"</a></font><br>";
} else {
myDisplay += "<font color=\""+myColor+"\"><a href=\"asfunctionlaySong,"+i+"\">"+myArtistName+ " "+mySongName+"</a></font><br>";
}
}
this.myDisplayText.htmlText = myDisplay;
//trace(this.scroller.getScrollPosition());
if (this.currentSong>6 && this.songNos>6) {
if (this.scroller.getScrollPosition()<this.currentSon g-5) {
this.scroller.setScrollPosition(this.currentSong-5);
} else if (this.scroller.getScrollPosition()>(this.currentSo ng+1)) {
this.scroller.setScrollPosition(this.currentSong-5);
}
} else {
this.scroller.setScrollPosition(1);
}
};
// ***************plays the song passed in the argument**************************
MovieClip.prototype.playSong = function(songNo) {
//trace("Now playing song: "+songNo);
var songURL = this.PlayList.Songs["src"+songNo];
if (this.streamSound) {
var stream = true;
} else {
var stream = true;
}
mySong = new Sound();
mySong.stop();
mySong.loadSound(songURL, stream);
mySong.baseClip = this;
mySong.onLoad = function() {
this.start();
};
mySong.onSoundComplete = function() {
this.baseClip.getNextSong();
};
this.currentSong = songNo;
this.displayPlayList();
this.playPause.gotoAndStop(2);
};
// ***************plays the next song **************************
MovieClip.prototype.getNextSong = function() {
if (this.currentSong<(this.songNos-1)) {
this.currentSong++;
} else {
this.currentSong = 0;
}
this.playSong(this.currentSong);
};
// ***************plays the previous song **************************
MovieClip.prototype.getPrevSong = function() {
if (this.currentSong>0) {
this.currentSong--;
} else {
this.currentSong = (this.songNos-1);
}
this.playSong(this.currentSong);
};
// **********pauses the song*******************
MovieClip.prototype.stopSong = function() {
mySong.stop();
};
// preloader function
MovieClip.prototype.startPreLoad = function(objectToLoad) {
//trace("**************start loading "+objectToLoad);
preLoader.loadBar.myObject = objectToLoad;
preLoader.loadBar.onEnterFrame = function() {
trace("myObj="+[this.myObject]+" | nowloaded="+[[this.myObject]+".getBytesLoaded"]());
this._xscale = ([[this.myObject]+".getBytesLoaded"]()/[[this.myObject]+".getBytesTotal"]())*100;
if ([[this.myObject]+".getBytesLoaded"]() == [[this.myObject]+".getBytesTotal"]() && [[this.myObject]+".getBytesTotal"]() != 0) {
trace("done loading");
this.onEnterFrame = null;
}
};
};
this.display.loadSongList("playlist.xml");

stop();



can someone please give me a little light.
here are the attached files:
Attached Files
File Type: zip flashampmodified.zip (142.0 KB, 145 views)

Last edited by purplefish32; 10-28-2004 at 02:59 PM.
purplefish32 is offline   Reply With Quote
Old 10-28-2004, 02:53 PM   #2
purplefish32
Registered User
 
Join Date: Jul 2003
Posts: 16
Default

sorry for the smilies... = ": P"
purplefish32 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:28 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.