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

Problema Con AudioFileFormat

Estas en el tema de Problema Con AudioFileFormat en el foro de Java en Foros del Web. String duration; duration = this.getDurationWithMp3Spi(st);//st es el file que cargo.(El file es de formato mp3) public String getDurationWithMp3Spi(File file) throws UnsupportedAudioFileException, IOException { AudioFileFormat fileFormat ...
  #1 (permalink)  
Antiguo 18/07/2012, 13:22
 
Fecha de Ingreso: julio-2012
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Exclamación Problema Con AudioFileFormat

String duration;

duration = this.getDurationWithMp3Spi(st);//st es el file que cargo.(El file es de formato mp3)

public String getDurationWithMp3Spi(File file) throws UnsupportedAudioFileException, IOException {

AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(file);
if (fileFormat instanceof AudioFileFormat) {
Map<?, ?> properties = ((AudioFileFormat) fileFormat).properties();
String key = "duration";
Long microseconds = (Long) properties.get(key);
int mili = (int) (microseconds / 1000);
int sec = (mili / 1000) % 60;
int min = (mili / 1000) / 60;
System.out.println("time = " + min + ":" + sec);
String ti = String.valueOf(min)+":"+String.valueOf(sec);
return ti;
} else {
throw new UnsupportedAudioFileException();
}

todo bien solo que al hacer AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(file); falla por que no soporta el tipo de archivo

ayudaaaaa pliss !!
  #2 (permalink)  
Antiguo 18/07/2012, 17:32
Avatar de zero0097  
Fecha de Ingreso: abril-2010
Ubicación: México
Mensajes: 481
Antigüedad: 14 años
Puntos: 69
Respuesta: Problema Con AudioFileFormat

Java por si solo no soporta la reproducción de archivos .mp3 ya que esta extensión de archivos no es OpenSource y requiere una licencia....

De esta manera puedes obtener los formatos disponibles...
Código Java:
Ver original
  1. AudioFileFormat.Type[] tipos = AudioSystem.getAudioFileTypes();
  2.  
  3. for(AudioFileFormat.Type x : tipos) {
  4.        System.out.println(x.getExtension());
  5. }

Si quieres reproducir MP3 te recomiendo javazoom! es sencilla y fácil de implementar y sirve para más formatos...
__________________
De nada, hay te encargo +1...
  #3 (permalink)  
Antiguo 18/07/2012, 20:01
 
Fecha de Ingreso: julio-2012
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Información Respuesta: Problema Con AudioFileFormat

Cita:
Iniciado por zero0097 Ver Mensaje
Java por si solo no soporta la reproducción de archivos .mp3 ya que esta extensión de archivos no es OpenSource y requiere una licencia....

De esta manera puedes obtener los formatos disponibles...
Código Java:
Ver original
  1. AudioFileFormat.Type[] tipos = AudioSystem.getAudioFileTypes();
  2.  
  3. for(AudioFileFormat.Type x : tipos) {
  4.        System.out.println(x.getExtension());
  5. }

Si quieres reproducir MP3 te recomiendo javazoom! es sencilla y fácil de implementar y sirve para más formatos...

Muchas gracias, todo claro y comenzare con javazoom Saludos !!

Etiquetas: audiofileformat, string
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




La zona horaria es GMT -6. Ahora son las 15:12.