Hi i have created a simple media player in flash that uses xml to pull and play tracks.
i looked at the basic mediaplayer example in the INTRO to XML tutorials on Kirupa.
I have also reviewed the “squirrel menu” example since i need the mp3 tracks to be played from a DYNAMIC list (when clicked on - that particular track plays in the mp3 player.)
I have used a nested loop to define the <cd> nodes and the <mp3 track> nodes within each <cd> node.
my issue is how do i play a specific track from a specific cd?
i tried to reference the particular node and childnodes - but i get unable to open file error!
the code pulling and generating everything is as follows:
var item_spacing = 110;
var item_count = 0;
var tracklist = new Array();
var menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(success){
if (success) {
var items = menu_xml.firstChild.childNodes;
for (var i=0; i<items.length; i++) {
var cd = items*;
var pic = items*.attributes.thumb;
var tracks = items*.attributes.tracktitles;
var artist = items*.attributes.artistname;
var albumName = items*.attributes.albumtitle;
var item_mc = menu_mc.attachMovie("item_panel","item"+item_count, item_count); // linkageID, name, depth
item_mc._y = item_count * item_spacing;
item_count++;
item_mc.artistDisplay.text = "Artist: " +artist;
item_mc.albumDisplay.text = "Album: " +albumName;
item_mc.tracklisting.text = tracks;
item_mc.icon_border.icon_mov.loadMovie(pic);
item_mc.icon_border.icon_mov._x= 0;
item_mc.icon_border.icon_mov._y= 0;
item_mc.icon_border.onRelease = function () {
playTrack();
}
}
var theTrack = cd.childNodes; //theTrack=song
for (var i=0; i<theTrack.length; i++) {
var currTrack = theTrack*.attributes.file; //track=currTrack
_root.tracklist.push(currTrack);
}
}
}
menu_xml.load("mix_playlist.xml");
// MEDIA PLAYER CONTROLS
function playTrack(){
_root.test_box.text= "hey";
stopAllSounds();
var x:Number = _global.trackNo;
var tlength:Number = _root.tracklist.length;
if (tlength <= x) {
//reset ffw counter
x = 0;
}
_global.trackNo = x;
_root.track = new Sound();
track.onID3 = function ()
{
tplay.trackID3Info.text = "";
tplay.trackID3Info.text += "Title: " + track.id3.TIT2 + newline;
tplay.trackID3Info.text += "Artist: " + track.id3.TPE1 + newline;
tplay.AlbumInfo.text += "Album: " + track.id3.TALB + newline;
tplay.AlbumInfo.text += "Genre: " + track.id3.COMM +
newline;
};
track.loadSound (tracklist[0], true);
}
forgive me about the indenting - i am a beginner with coding!
I know that the key is in the last line track.loadsound(tracklist[0])…maybe i should be targetting something else? to get a better idea of what i am trying to do please take a look at: www.ragemultimedia.com/theheadz/mixlisttest.htm