hi everyone
I’m working on a project for varsity, I’ve created a music player but every time I publish it in Firefox i get multiple errors, (in IE it’s perfectly fine though) but otherwise it’s just not playing any music by default. I’ve read the other forums that cover these errors but I still don’t understand why I’m getting these:
[COLOR=Red]ArgumentError: Error #2068: Invalid sound.
at flash.media::Sound/play()
at index_fla::MainTimeline/playSong()
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at index_fla::MainTimeline/nextSong()[/COLOR]
My current scripting for the mplayer:
[COLOR=RoyalBlue]var musicReq: URLRequest;
var music:Sound = new Sound();
var sndC:SoundChannel;
var currentSnd:Sound = music;
var currentIndex:Number = 0;
var xml:XML;
var songList:XMLList;
var loader:URLLoader = new URLLoader();
currentSnd.addEventListener(IOErrorEvent.IO_ERROR, soundIOErrorHandler);
function soundIOErrorHandler(event:IOErrorEvent)
{
//error suppression
}
loader.addEventListener(Event.COMPLETE, Loaded);
loader.load(new URLRequest(“music/musiclist.xml”));
function Loaded(e:Event):void{
xml = new XML(e.target.data);
songList = xml.song;
musicReq = new URLRequest(songList[0].url);
music.load(musicReq);
sndC = music.play();
this.mplayer_holder_mc.mplayer_mc.song_txt.text = songList[0].title;
this.mplayer_holder_mc.mplayer_mc.artist_txt.text = songList[0].artist;
sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
this.mplayer_holder_mc.mplayer_mc.prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
this.mplayer_holder_mc.mplayer_mc.next_btn.addEventListener(MouseEvent.CLICK, nextSong);
this.mplayer_holder_mc.mplayer_mc.play_btn.addEventListener(MouseEvent.CLICK, playSong);
this.mplayer_holder_mc.mplayer_mc.stop_btn.addEventListener(MouseEvent.CLICK, stopSong);
function prevSong(e:Event):void{
if(currentIndex > 0){
currentIndex–;
}
else{
currentIndex = songList.length() -1;
}
var prevReq:URLRequest = new URLRequest(songList[currentIndex].url);
var prevPlay:Sound = new Sound(prevReq);
sndC.stop();
this.mplayer_holder_mc.mplayer_mc.song_txt.text = songList[currentIndex].title;
this.mplayer_holder_mc.mplayer_mc.artist_txt.text = songList[currentIndex].artist;
sndC = prevPlay.play();
currentSnd = prevPlay;
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=false;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=true;
sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function nextSong(e:Event):void {
if(currentIndex < (songList.length() - 1)){
currentIndex++;
}
else {
currentIndex = 0;
}
var nextReq:URLRequest = new URLRequest(songList[currentIndex].url);
var nextPlay:Sound = new Sound(nextReq);
sndC.stop();
this.mplayer_holder_mc.mplayer_mc.song_txt.text = songList[currentIndex].title;
this.mplayer_holder_mc.mplayer_mc.artist_txt.text = songList[currentIndex].artist;
sndC = nextPlay.play();
currentSnd = nextPlay;
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=false;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=true;
sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function playSong(e:Event):void{
sndC = currentSnd.play(0, int.MAX_VALUE);
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=false;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=true;
}
function stopSong(e:Event):void{
sndC.stop();
this.mplayer_holder_mc.mplayer_mc.play_btn.visible=true;
this.mplayer_holder_mc.mplayer_mc.stop_btn.visible=false;
}
[/COLOR]
Also for the spectrum I get this output error:
[COLOR=Red]TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/spectrum()[/COLOR]
And the script:
[COLOR=RoyalBlue]stage.addEventListener(Event.ENTER_FRAME, spectrum);
function spectrum(Event):void {
this.mplayer_holder_mc.mplayer_mc.spectrum_mc.leftSpec1_mc.height = 20 * sndC.leftPeak;
…[it repeats the same function for a other movieClips]
}[/COLOR]
My scripts are on separate layers to make coding easier to categorise but primarily they’re all in the same frame.
Any help is much appreciated.
Thank you :deranged: