It's not a big issue to read metadata from an mp3 file . you just need to include library . The code is
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import org.cmc.music.common.ID3ReadException;
import org.cmc.music.metadata.IMusicMetadata;
import org.cmc.music.metadata.MusicMetadataSet;
import org.cmc.music.myid3.MyID3;
import org.cmc.music.myid3.id3v2.MyID3v2;
import org.cmc.music.myid3.id3v2.MyID3v2Write;
public class sound {
public static void readSound(File src){
try {
MusicMetadataSet src_set = new MyID3().read(src);
if (src_set != null){
IMusicMetadata metadata =src_set.getSimplified();
String artist = metadata.getArtist();
String album = metadata.getAlbum();
String song_title = metadata.getSongTitle();
List commts = metadata.getComments();
String Des=metadata.getGenreName();
System.out.println(artist);
System.out.println(song_title);
System.out.println(Des);
System.out.println(album);
System.out.println(commts);
}
} catch (ID3ReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
String path="a.mp3";
File src=new File(path);
readSound(src);
}
No comments:
Post a Comment