Results 1 to 4 of 4

Thread: XML MP3 player

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default XML MP3 player

    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.
    Code:
    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

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    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.

  3. The Following User Says Thank You to Medyman For This Useful Post:

    nate51 (06-13-2008)

  4. #3
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    That did it.

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

  5. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by nate51 View Post
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •