Search code examples
javastringmp3

read tags from mp3 file


I have a code that reads the mp3 tag, it's the last 128 bytes of the file

try{
    final int TAG_LONG = 128;
    fileInputStream = new FileInputStream(file.getAbsolutePath());
    byte[] bytesSong = new byte[128];
    byte[] byteTitleArry = new byte[length];
    for (int i = 0; i < 30; i++) {
        byteTitleArry[i] = arrayTag[3+ i];
    }
    String title = new String(byteTitleArry);
}

this code works just fine when the title tag (or enything else) is written english chars, but when the tag is a value in non-english chars i get the wrong value, so i used:

String title = new String(byteTitleArry, "ISO-8859-8");

but this is not generic enough, is there a way to find out what is the tag unicode?


Solution

  • Try using an ID3 library instead, e.g. JAudioTagger.