Log in

View Full Version : XML MP3 player



nate51
05-16-2008, 09:33 PM
I have an XML run MP3 player on my site and for some wierd reason when I play it off my desktop (the site that is) it all works fine, when I made a sub directory on my server, still worked fine then when I uploaded everything to the main directory to go live, the player has a progress bar for the track that fills too fast when it's playing and the song gets cut off then it jumps to the next song, like it believes the song is over.

This is the AS I have on the player.

function reposition() {
var playermc = _root.player;

var nPos;

nPos = getNewPosition(playermc);
playermc._x = 0;
playermc._y = Stage.height - playermc._height;

};

function getNewPosition(mc) {
var newX = Math.floor((Stage.width - mc._width) / 2);
var newY = Math.floor((Stage.height - mc._height) / 2);
return {x:newX, y:newY};
};

reposition();

function convertXML():Object
{
//Defines the object used to store all track information from the XML file
var tracksData = {};
tracksData.titles = new Array();
tracksData.artists = new Array();
tracksData.urls = new Array();
//The base node has been set to a variable to shorten code and make
//things easier when modifying.
var tracks = xml.firstChild.childNodes;
//I've set the number of tracks specified in the XML file to a variable to
//save Flash the trouble of looking this number up everytime the for loop
//is executed. This technique can save a bit of time with big loops.
var tracksCount = tracks.length;

for(var i = 0; i < tracksCount; i++)
{
//Appends the node values of each category to the tracksData object
//in the relative category/array.
tracksData.titles.push(tracks[i].childNodes[0].firstChild.nodeValue);
tracksData.artists.push(tracks[i].childNodes[1].firstChild.nodeValue);
tracksData.urls.push(tracks[i].childNodes[2].firstChild.nodeValue);
}
return tracksData;
}

var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success:Boolean)
{
if(success)
{
var player = new MusicPlayer(player, convertXML(), this.firstChild.attributes.initTrackID);
}
else
{
trace("Unable to load XML.");
}
}
//Begins loading XML
xml.load("tracks.xml");

stop();

I am stumped on this, does anyone see any errors in the code that may be causing this?


-- Nate

Medyman
05-16-2008, 10:13 PM
I don't see anything wrong with the code. And if it works on your local machine as well as on your server, I doubt the coding is at fault.

Do you have to link to the player that's in your "main" directory so I can see the behavior? I'm not sure I understand what's going on.

Are you sure that the mp3 was uploaded correctly? Reupload the MP3 in binary mode and try it again.

nate51
06-13-2008, 03:37 AM
That did it.

Thanks for the help. I would have never though to change that part.

Medyman
06-13-2008, 12:15 PM
That did it.

Thanks for the help. I would have never though to change that part.

Yeah, the upload mode is pretty important. All media (images, audio, video, flash and other binary files) should be sent in binary mode and all text-based files (html, xml, php, etc..) in ASCII mode.