PDA

View Full Version : Mp3 Player Help


moos3
09-24-2007, 04:00 PM
I need some help with a mp3 player that I wrote.

// This is the MP3 player Logic
// Written By Moos3
// Site http://guthnur.net
// Written for the purpose of learning flash
// This released under the heck of it software

// make sound obect
var mp3:Sound = new Sound();
mp3.onSoundComplete = playSong;
mp3.setVolume(75);

// ID3 Track info
var songInfo:Object;

// array of Songs
var mp3s:Array = new Array();

// Current Playing song
var cps:Number = -1;

// Position
var pos:Number;

// button states
var btnState:Boolean;
var pauseState:Boolean;
var muteState:Boolean;

// XML Loader
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(){
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++){
mp3s.push(nodes[i].attributes.url);
}
playSong();
}
xml.load("playlist.xml");

// Get Song infromation
function songTag():Void{
mp3.onID3;
songinfo = this.id3;
info.mp3info.text = songInfo.artist + ' -- ' + songInfo.songName;
}

// Play Song Fuction
// This Plays the mp3 file
function playSong():Void{
if(cps == sa.length-1){
cps =0;
mp3.loadSound(mp3s[cps],true);
this._parent.songTag();
}
else{
mp3.loadSound(mp3s[++cps],true);
this._parent.songTag();
}
}
// Function Pausing the Song
function pauseIt():Void{
pos = mp3.position;
mp3.stop();
}
// Function unpause the Song
function unpauseIt():Void{
mp3.start(pos/1000);
}
//Stop the Song
function stopSong():Void{
mp3.stop();
btnState = true;
}

// Interface Buttons
// Stop Bustton
btnStop.onRelease = function(){
this._parent.stopSong();

}
// next button
btn_next.onRelease = function(){
this._parent.playSong();
}
// Play button
btn_play.onRelease = function(){
if(btnState == true){
this._parent.playSong();
//store the Current Song
cps = mp3s.length;
btnState = false;
}
if(pauseState == true){
this._parent.pauseIt();
pauseState = false;
}
}
// Last Song Button
btn_prev.onRelease = function(){
this._parent.playSong();
cps = cps-1;
}
// Pause Button
btn_pause.onRelease = function(){
if(pauseState == false){
this._parent.pauseIt();
pauseState = true;
}
else{
this._parent.unpauseIt();
pauseState = false;
}
}
// Mute Button
btn_mute.onRelease = function(){
if(muteState == false){
mp3.setVolume(0);
muteState = true;
}
else{
mp3.setVolume(75);
muteState = false;
}
}

For some reason my pause button and play buttons are advancing to the next track and my ID3 information function isn't writing out. Before when I have it inside the play function it was working but not changing with the change of song. Any ideas?

gnomeontherun
09-25-2007, 05:52 AM
Did you do a trace to see if the information is getting loaded, and if it is are you sure it is referenced correctly? That might be the best place to look for the text issue.

Did you get this from gotoandlearn.com?