Foros del Web » Programación para mayores de 30 ;) » Java »

Reproductor java

Estas en el tema de Reproductor java en el foro de Java en Foros del Web. Hola amigos y amigas quisiera saber si me podrian decir como puedo crear un programa para que pueda reproducir archivos con extencion .mp3 ya que ...
  #1 (permalink)  
Antiguo 09/05/2007, 13:05
(Desactivado)
 
Fecha de Ingreso: julio-2006
Mensajes: 273
Antigüedad: 17 años, 8 meses
Puntos: 5
Reproductor java

Hola amigos y amigas quisiera saber si me podrian decir como puedo crear un programa para que pueda reproducir archivos con extencion .mp3 ya que solo tengo el sig. codigo que solo produce archivos .wav

import java.applet.AudioClip;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;

public class Reproductor extends JApplet
{
private AudioClip sound1, sound2, sound3,sound4,currentSound;
private JButton playJButton, loopJButton, stopJButton;
private JComboBox soundJComboBox;

// load the image when the applet begins executing
public void init()
{
setLayout( new FlowLayout() );

String choices[] = { "Caballo","Elefante","Gallo","Oveja" };
soundJComboBox = new JComboBox( choices ); // create JComboBox

soundJComboBox.addItemListener(

new ItemListener() // anonymous inner class
{
// stop sound and change to sound to user's selection
public void itemStateChanged( ItemEvent e )
{
currentSound.stop();
currentSound = soundJComboBox.getSelectedIndex() == 0 ?
sound1 : sound2;

} // end method itemStateChanged
} // end anonymous inner class
); // end addItemListener method call

add( soundJComboBox ); // add JComboBox to applet

// set up button event handler and buttons
ButtonHandler handler = new ButtonHandler();

// create Play JButton
playJButton = new JButton( "Reproducir" );
playJButton.addActionListener( handler );
add( playJButton );

// create Loop JButton
loopJButton = new JButton( "Repetir" );
loopJButton.addActionListener( handler );
add( loopJButton );

// create Stop JButton
stopJButton = new JButton( "Detener" );
stopJButton.addActionListener( handler );
add( stopJButton );

// load sounds and set currentSound
sound1 = getAudioClip( getDocumentBase(), "Caballo.wav" );
sound2 = getAudioClip( getDocumentBase(), "Elefante.wav" );
sound3 = getAudioClip( getDocumentBase(), "Gallo.wav" );
sound4 = getAudioClip( getDocumentBase(), "Oveja.wav" );
currentSound = sound1;
} // end method init

// stop the sound when the user switches Web pages
public void stop()
{
currentSound.stop(); // stop AudioClip
} // end method stop

// private inner class to handle button events
private class ButtonHandler implements ActionListener
{
// process play, loop and stop button events
public void actionPerformed( ActionEvent actionEvent )
{
if ( actionEvent.getSource() == playJButton )
currentSound.play(); // play AudioClip once
else if ( actionEvent.getSource() == loopJButton )
currentSound.loop(); // play AudioClip continuously
else if ( actionEvent.getSource() == stopJButton )
currentSound.stop(); // stop AudioClip
} // end method actionPerformed
} // end class ButtonHandler
} // end class LoadAudioAndPlay

gracias.
  #2 (permalink)  
Antiguo 02/03/2012, 17:07
 
Fecha de Ingreso: junio-2008
Mensajes: 34
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Reproductor java

AudioClip sonidoFondo = Applet.newAudioClip(getClass().getResource("sonido s/intro.wav"));
sonidoFondo.play();
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 19:23.