简体   繁体   中英

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?

尝试改用ID3库,例如JAudioTagger

It seems that the ID3v1 you are trying to use does not hold any i18n information. ID3v2 however does. Source: http://en.wikipedia.org/wiki/ID3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM