I have a simple mp3 player that loads into IE and not Firefox :S
www.mun-design.com/zenydesigns/English
To load it onto my MAIN movie im using this code
PHP Code:
stop();
var mp3:Loader = new Loader()
mp3.load(new URLRequest("ipod.swf"))
addChild(mp3)
mp3.x=700;
mp3.y=700;
And on the swf itself I have this:
PHP Code:
var getMusic:URLRequest;
var music:Sound = new Sound();
var soundChannel:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var currentIndex:Number = 0;
var songPlaying:Boolean = false;
var xml:XML;
var songlist:XMLList;
function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
if(percentLoaded > 20){
trace("loading");
} else{
}
}
function completeHandler(event):void {
trace("DONE");
}
/*-------------------Load in Our XML ------------------------*/
/*----------------------------------------------------------*/
var loader:URLLoader = new URLLoader(); //create a new URLLoader Object
loader.addEventListener(Event.COMPLETE, whenLoaded); //add an event listener to that object
loader.load(new URLRequest("songs.xml")); //Requests our xml file that contains our song data
function whenLoaded(e:Event):void //WhenLoaded function(see line 50) runs when line 50 is complete
{
xml = new XML(e.target.data);
songlist = xml.song; //accesses our song tag in our xml file
getMusic = new URLRequest(songlist[0].url);//get music from songlist
music.load(getMusic);//load music
soundChannel = music.play();//plays the music
songTXT.text = songlist[0].title; //gets song name from xml
artistTXT.text = songlist[0].artist; //gets artist name
albumTXT.text = songlist[0].album; //gets album name
soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);//runs the next song function when a song completes
}
/*--------ads some mouse events to our buttons----------------------------------------*/
next_btn.addEventListener(MouseEvent.CLICK, nextSong);
prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);
/*--------Skips Songs----------------------------------------*/
/*-most of below the vars is explained above---------*/
function nextSong(e:Event):void
{
if (currentIndex < (songlist.length() - 1))
{
currentIndex++;
}
else
{
currentIndex = 0;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var nextTitle:Sound = new Sound(nextReq);
soundChannel.stop();
songTXT.text = songlist[currentIndex].title;
artistTXT.text = songlist[currentIndex].artist;
albumTXT.text = songlist[currentIndex].album;
soundChannel = nextTitle.play();
songPlaying = true;
currentSound = nextTitle;
soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
/*--------Previous song and acceses the information in the xml File--------------------------*/
/*--------most of below the vars is explained above-------------------------*/
function prevSong(e:Event):void
{
if (currentIndex > 0)
{
currentIndex--;
}
else
{
currentIndex = songlist.length() - 1;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var prevTitle:Sound = new Sound(nextReq);
soundChannel.stop();
songTXT.text = songlist[currentIndex].title;
artistTXT.text = songlist[currentIndex].artist;
albumTXT.text = songlist[currentIndex].album;
soundChannel = prevTitle.play();
songPlaying = true;
currentSound = prevTitle;
soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function pauseSong(e:Event):void
{
pos = soundChannel.position; //pause song at current position
soundChannel.stop(); //stop sound
songPlaying = false; // songPlaying is now equal to false
play_btn.addEventListener(MouseEvent.CLICK,playSong);
}
function playSong(e:Event):void
{
if(songPlaying == false) //if songplaying is equal to false run function below
{
soundChannel = currentSound.play(pos); //play from current position(used if it was paused)
soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);//run nextSong function if current song is complete
songPlaying = true; //songPlaying is now true
play_btn.removeEventListener(MouseEvent.CLICK,playSong);
}
}
I am at a complete blank as to what I can do to fix this I dont even know where to begin haha.. any help would be appreciated! Thanks!