Comunidad de diseño web y desarrollo en internet online

Repoductor mp3

Citar            
MensajeEscrito el 01 Abr 2009 02:18 pm
hola, como estan?

bueno les comento. estoy con un reproductor de mp3 el cual consta de dos botones (playPause y otro para adelantar los temas), incluye un .as llamado mp3Player.as, los sonidos son importados desde una archivo xml llamado songs.xml con el siguiente codigo:

Código :

<?xml version="1.0" encoding="UTF-8"?>
<songs>
   <song url="musica/01.mp3" artist="Artista" track="artista" />
   <song url="musica/02.mp3" artist="Artista" track="artista" />
   <song url="musica/03mp3" artist="Artista" track="Bled White" />
   <song url="musica/04.mp3" artist="Artista" track="Marching bands of Manhattan" />
   <song url="musica/05.mp3" artist="Artista" track="Pass It On" />
</songs>


. funciona correctamente y demas.

lo q quiero lograr es cambiar el btn para adelantar los temas, por ej: poner un btn q sea un "3", al clikearlo reproduzca el tema 3 de mi xml. Como puedo hacerlo?

En el .as estas son las acciones asignadas para el boton "next".

Código :

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

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

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


espero alguna ayuda. desde ya gracis. :)

Por Rakin

Claber

140 de clabLevel



 

firefox
Citar            
MensajeEscrito el 01 Abr 2009 05:30 pm
Está llamando a un método playSong con argumento cero, fíjate que hace ese método

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 01 Abr 2009 05:34 pm
Perdon, en realidad es:

Código :

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


Me confundi al copiarlo. Es ahi donde deberia cambiar?

Por Rakin

Claber

140 de clabLevel



 

firefox
Citar            
MensajeEscrito el 01 Abr 2009 05:38 pm
Entonces mira que dice el método playSong

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 03 Abr 2009 01:58 pm
la verdad q no logro comprender del todo el as

Código :

// 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<nodes.length;i++)
   {
      sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].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(sa[cps].earl, true);
   }
   else
   {
      s.loadSound(sa[++cps].earl, true);
   }
   trackInfo.text = sa[cps].artist + " - " + sa[cps].track;
   playPause.gotoAndStop("pause");
   textPos = 0;
}

// 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);
   }
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Text scroller bonus code

var size:Number = 21;
var textPos:Number = 0;
var intervalID:Number = setInterval(scroller, 1000);

function scroller():Void
{
   var t:String = (sa[cps].artist + " - " + sa[cps].track);
   if(textPos+size < t.length)
   {
      textPos++;
      trackInfo.text = (sa[cps].artist + " - " + sa[cps].track).substring(textPos, textPos+size);
   }
   else 
   {
      clearInterval(intervalID);
      intervalID = setInterval(scroller2, 1000);
   }
}

function scroller2():Void
{
   var t:String = (sa[cps].artist + " - " + sa[cps].track);
   if(textPos > 0)
   {
      textPos--;
      trackInfo.text = (sa[cps].artist + " - " + sa[cps].track).substring(textPos, size);
   }
   else 
   {
      clearInterval(intervalID);
      intervalID = setInterval(scroller, 1000);
   }
}

Por Rakin

Claber

140 de clabLevel



 

firefox
Citar            
MensajeEscrito el 03 Abr 2009 02:20 pm
Está mandando a cargar el tema en mnodo streaming, La variable que usa como contador es cps, Entonces tu botón podría hacer algo así:

Código ActionScript :

tematres.onPress - function(){
   cps = 1
   playSong()
}


Es un poco tricky, porque para pasar el tema 3, le paso el nro 1, esto obedece a dos cosas:

- El arrrray de temas empieza por cero
- El método playSong lo incrementa en 1

Sino puedes crear un método paralelo, playSoundNumber(nr) que reproduzca directamente un tema específico

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.