|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#2 |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
...ciao...
...utilizzando le librerie javazoom risulta abbastanza semplice... ...il sito da cui scaricare le librerie è questo http://www.javazoom.net/index.shtml... ...ed ecco una classe esempio... Codice:
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import javax.sound.sampled.AudioSystem;
import org.tritonus.share.sampled.file.TAudioFileFormat;
public class Mp3Tag {
public void trackInfo(String filename){
File file = new File(filename);
try {
TAudioFileFormat taff = (TAudioFileFormat)AudioSystem.getAudioFileFormat(file);
Map map = taff.properties();
Iterator it = map.keySet().iterator();
while(it.hasNext())
{
String key = (String) it.next();
String val=(map.get(key)).toString();
System.out.println(key +" "+ val);
}
if (map.get("mp3.length.bytes")!=null && map.get("mp3.framesize.bytes") != null && map.get("mp3.framerate.fps")!= null)
{
float f1 = Float.valueOf(map.get("mp3.length.bytes")+"").floatValue();
float f2 = Float.valueOf(map.get("mp3.framesize.bytes")+"").floatValue();
float f3 = Float.valueOf(map.get("mp3.framerate.fps")+"").floatValue();
String inter = ((f1/(f2*f3))+"");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
}
public static void main (String args[]){
Mp3Tag flg = new Mp3Tag();
flg.trackInfo("c:/Confessioni di un malandrino.mp3");
}
}
|
|
|
|
|
|
#3 |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
...ah per la cronaca la parte all'interno dell'if permette di ricavare il dato della lunghezzza del brano in modo piu' sicuro...sopratutto nel caso di file con framerate variabile...
...ciao... |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Oct 2004
Città: Rovereto (tn)
Messaggi: 2187
|
grazie..
solo: quali sono le librerie da scaricare? come ricavo titolo autore e album? ciaooo |
|
|
|
|
|
#7 | |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
Quote:
...si scusa ma ho problemi con l'ftp... ...le librerie tritonus dovrebbero essere abbasatanza semplici da reperire...hai fatto una ricerca su google?... ...ciao... |
|
|
|
|
|
|
#8 | |
|
Senior Member
Iscritto dal: Oct 2004
Città: Rovereto (tn)
Messaggi: 2187
|
Quote:
ma quale? |
|
|
|
|
|
|
#9 |
|
Senior Member
Iscritto dal: Oct 2004
Città: Rovereto (tn)
Messaggi: 2187
|
ok trovate..
ora ho un problema.. mi dice questo: Codice:
javax.sound.sampled.UnsupportedAudioFileException: file is not a supported file type at javax.sound.sampled.AudioSystem.getAudioFileFormat(Unknown Source) at pkgTest.MainTest.trackInfo(MainTest.java:17) at pkgTest.MainTest.main(MainTest.java:47) javax.sound.sampled.UnsupportedAudioFileException: file is not a supported file type |
|
|
|
|
|
#10 |
|
Bannato
Iscritto dal: Jan 2003
Città:
Messaggi: 4421
|
...ciao...
...hai fatto puntare il file ad un corretto mp3?... ...ciao... |
|
|
|
|
|
#11 | |
|
Senior Member
Iscritto dal: Oct 2004
Città: Rovereto (tn)
Messaggi: 2187
|
Quote:
delle librerire io ho scaricato questa:tritonus_share-0.3.6.jar (101 kB) |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 02:38.



















