I have some AS3 MP3 code that my teacher gave me a while ago and it loads perfectly when I load the site locally on my computer, but I uploaded the site to my server and the MP3 doesn't load at all, but the rest of the site is fine. Since I'm not great at AS3 and don't quiet understand everything that is going on I'm just going to post the MP3 code in its entirety just in case any of you can spot why it won't load online. By the way I only bought the basic server space from bluehost.com. I did not purchase a media server (which I really don't know what it does). Could this be the problem?
var songList:Array = new Array("InBackRoom.mp3", "NoMeansYes.mp3");
var isPlaying:Boolean = false;
var currentSong:Number = 0;
var song:Sound;
var channel:SoundChannel = new SoundChannel();
var xform:SoundTransform = new SoundTransform();
seekKnob.buttonMode = true;
seekKnob.addEventListener(MouseEvent.MOUSE_DOWN, seekStartDrag);
btnPrev.addEventListener(MouseEvent.CLICK, prevHandler);
btnPause.addEventListener(MouseEvent.CLICK, pauseHandler);
btnPlay.addEventListener(MouseEvent.CLICK, playHandler);
btnNext.addEventListener(MouseEvent.CLICK, nextHandler);
volumeKnob.buttonMode = true;
volumeKnob.addEventListener(MouseEvent.MOUSE_DOWN, volumeStartDrag);
function prevHandler(evt:MouseEvent):void {
prevSong();
}
function pauseHandler(evt:MouseEvent):void {
pauseSong();
}
function playHandler(evt:MouseEvent):void {
playSong(channel.position);
}
function nextHandler(evt:MouseEvent):void {
nextSong();
}
function id3Handler(evt:Event):void {
songInfo.text = /*song.id3.artist + ": " +*/ song.id3.songName;
}
function soundCompleteHandler(evt:Event):void {
pauseSong();
nextSong();
}
loadSong(songList[currentSong]);
function loadSong(thisSong:String):void {
song = new Sound();
song.load(new URLRequest(thisSong));
song.addEventListener(Event.ID3, id3Handler);
/*playSong(0);*/
}
function playSong(position:Number):void {
if (!isPlaying) {
isPlaying = true;
channel = song.play(position);
channel.soundTransform = xform;
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
seekKnob.addEventListener(Event.ENTER_FRAME, seekKnobUpdate);
}
}
function pauseSong():void {
seekKnob.removeEventListener(Event.ENTER_FRAME, seekKnobUpdate);
channel.stop();
isPlaying = false;
}
function prevSong():void {
if (currentSong > 0) {
currentSong--;
pauseSong();
loadSong(songList[currentSong]);
}
}
function nextSong():void {
if (currentSong < songList.length - 1) {
currentSong++;
pauseSong();
loadSong(songList[currentSong]);
}
}
function seekStartDrag(evt:MouseEvent):void {
pauseSong();
seekKnob.startDrag(true, new Rectangle(seekSlider.x, seekSlider.y + seekSlider.height/2, seekSlider.width, 0));
stage.addEventListener(MouseEvent.MOUSE_UP, seekStopDrag);
}
function seekStopDrag(evt:MouseEvent):void {
seekKnob.stopDrag();
playSong(song.length * (seekKnob.x - seekSlider.x) / seekSlider.width);
stage.removeEventListener(MouseEvent.MOUSE_UP, seekStopDrag);
}
function seekKnobUpdate(evt:Event):void {
var pos:Number = seekSlider.width * channel.position / song.length;
if (!isNaN(pos)) {
seekKnob.x = seekSlider.x + pos;
} else {
seekKnob.x = seekSlider.x;
}
}
function volumeStartDrag(evt:MouseEvent):void {
volumeKnob.startDrag(true, new Rectangle(volumeSlider.x, volumeSlider.y + volumeSlider.height/2, volumeSlider.width, 0));
volumeKnob.addEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate);
stage.addEventListener(MouseEvent.MOUSE_UP, volumeStopDrag);
}
function volumeStopDrag(evt:MouseEvent):void {
volumeKnob.removeEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate);
volumeKnob.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, volumeStopDrag);
}
function volumeUpdate(evt:MouseEvent):void {
xform.volume = (volumeKnob.x - volumeSlider.x) / volumeSlider.width;
channel.soundTransform = xform;
}
I checked and everything is uploaded and in the same, correct file structure that it should be.
It's not necessary to use a media server. Use a web debugger such as Firebug to see if the requests for the MP3 files are being made, to where they are being made and if the response is appropriate. It might be something as simple as case sensitivity in the url.