Telling my flash mp3 player to get its song list from an xml file
Hello,
What do I need to put in my code to tell my mp3 player to grab its songs from a folder on my server via an xml doc I outputted from my sql server? (the mp3 player is also on the server).
Thanks in advance! ![]()
Here's my code thus far:
Heres my code:
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import fl.events.SliderEvent;
var myMusic:Sound = new Sound();
var soundFile:URLRequest = new URLRequest("lpwfte.mp3");
var channel:SoundChannel = new SoundChannel();
var sTransform:SoundTransform = new SoundTransform();
var myTimer:Timer = new Timer(100);
var songPosition:Number = 0;
var myContext:SoundLoaderContext = new SoundLoaderContext(5000);
myMusic.load(soundFile, myContext);
myTimer.addEventListener(TimerEvent.TIMER, updateTime);
buttonPlay.addEventListener(MouseEvent.CLICK, playMusic);
btnStop.addEventListener(MouseEvent.CLICK, StopMusic);
sldVolume.addEventListener(SliderEvent.CHANGE, ChangeVolume);
myMusic.addEventListener(Event.COMPLETE, getSongLength);
btnPause.addEventListener(MouseEvent.CLICK, pauseMusic);
function pauseMusic(evt:MouseEvent):void
{
songPosition = channel.position;
channel.stop();
}
function convertTime(millis:Number):String
{
var Minutes:Number = ( millis % (1000*60*60)) / (1000 * 60);
var Seconds:Number = ((millis % (1000*60*60)) % (1000 * 60)) /1000;
if(Minutes < 10)
{
var displayMinutes:String = "0" + Math.floor(Minutes);
}else
{
var displayMinutes:String = Math.floor(Minutes).toString();
}
if(Seconds < 10)
{
var displaySeconds:String = "0" + Math.floor(Seconds);
}else
{
var displaySeconds:String = Math.floor(Seconds).toString();
}
return displayMinutes + ":" + displaySeconds;
//return (Math.floor(Minutes) + ":" + Math.floor(Seconds));
}
function updateTime(evt:TimerEvent):void
{
lblSongTime.text = convertTime(channel.position);
}
function getSongLength(evt:Event):void
{
lblSongTotalTime.text = convertTime(myMusic.length);
lblSongName.text = myMusic.id3.songName;
lblSongArtist.text = myMusic.id3.artist;
lblSongYear.text = myMusic.id3.year;
}
function ChangeVolume(evt:SliderEvent):void
{
sTransform.volume = sldVolume.value;
channel.soundTransform = sTransform;
}
function StopMusic(evt:MouseEvent):void
{
channel.stop();
songPosition = 0;
}
function playMusic(evt:MouseEvent):void
{
channel = myMusic.play(songPosition);
myTimer.start();
}
