//使用流打开的时候要注意,我们需要的是最后128字节的信息
public static void getID3V1(File file) throws IOException {
byte[] bytes = new byte[128];
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
//移动到最后128字节的位置
raf.seek(raf.length() - 128);
raf.read(bytes);
if ("TAG".equals(new String(bytes, 0, 3))) {
String temp;
temp = new String(bytes, 3, 30, "GBK").trim();
Log.d("getID3V2", "歌名" + temp);
temp = new String(bytes, 33, 30, "GBK").trim();
Log.d("getID3V2", "歌手" + temp);
temp = new String(bytes, 63, 30, "GBK").trim();
Log.d("getID3V2", "专辑" + temp);
temp = new String(bytes, 93, 4, "GBK").trim();
Log.d("getID3V2", "年份" + temp);
} else {
Log.d("getID3V2", "TIT2" + file.getName());
Log.d("getID3V2", "TPE1" + "未知");
Log.d("getID3V2", "专辑" + "未知");
Log.d("getID3V2", "年份" + "未知");
}
}
}
JAVA 获取ID3V1里的数据
于 2024-10-13 14:40:06 首次发布
2559

被折叠的 条评论
为什么被折叠?



