Your Ad Here

Tuesday, October 30, 2007

Fully functional mp3 player w/scrolling track info

Hey guys,

Im new to the site and I thought you guys could make a few suggestions and assist me. I have created an mp3 player with the play/pause toggle, next button, mute button, and track information text field. Now what I want to do is create a previous track button (back button) and I would like my track information to scroll horizontally. Does anyone know where I can find that tutorial or can someone share their knowledge on this? Thanks in advance. Your help is appreciated.

Here is my actionscript(this does not include the class actionscript or xml)

//Setup sound object
var s:Sound = new Sound ();
s.onSoundComplete = playSong;
s.setVolume(75);

//Array of Songs
var sa:Array = new Array();

//Currently playing song
var cps:Number = -1;

//Position of Music
var pos:Number;

//Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i{
sa.push(new Song(nodesi.attributes.url,nodesi.attributes.artist,nodesi.attributes.track));
}
playSong();
}

xml.load("songs.xml");

//Play the MP3 File
function playSong():Void
{
s = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
mute.gotoAndStop("on");
if(cps == sa.length -1)
{
cps = 0;
s.loadSound(sacps.earl, true);
}
else
{
s.loadSound(sa++cps.earl, true);
}
trackInfo.text = sacps.artist + " - " + sacps.track;
playPause.gotoAndStop("pause");
}

//Pauses the Music
function pauseIt():Void
{
pos = s.position;
s.stop();
}

//Pauses the Music
function unPauseIt():Void
{
s.start(pos/1000);
}

//Music Controls

//Play/Pause Toggle
playPause.onRollOver = function()
{
if(this._currentframe == 1)this.gotoAndStop("pauseOver");
else this.gotoAndStop("playOver");
}

playPause.onRollOut = playPause.onReleaseOutside = function()
{
if(this._currentframe == 10)this.gotoAndStop("pause");
else this.gotoAndStop("play");
}

playPause.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop("playOver");
this._parent.pauseIt();
}
else
{
this.gotoAndStop("pauseOver");
this._parent.unPauseIt();
}
}

//Next Button
next.onRollOver = function()
{
this.gotoAndStop("nextOver");
}

next.onRollOut = next.onReleaseOutside = function()
{
this.gotoAndStop("next");
}

next.onRelease = function()
{
this._parent.playSong();
}

//Mute Button
mute.onRollOver = function()
{
if(this._currentframe == 1)this.gotoAndStop("onOver");
else this.gotoAndStop("offOver");
}

mute.onRollOut = mute.onReleaseOutside = function()
{
if(this._currentframe == 10)this.gotoAndStop("on");
else this.gotoAndStop("off");
}

mute.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop("offOver");
s.setVolume(0);
}
else
{
this.gotoAndStop("onOver");
s.setVolume(75);
}
}

Topic Replies: 0

Read More...

[Source: Ozzu - Posted by FreeAutoBlogger]
Your Ad Here

No comments: