このjarファイルMyID3_for_androidをダウンロードして、プロジェクトのビルドパスに追加します。カバーを変更する方法のサンプルコードは次のとおりです
File src = new File("filepath");
MusicMetadataSet src_set = new MyID3().read(src);
File img = (new File("imagePath"));
Vector<ImageData> fileList = new Vector<ImageData>();
ImageData data = new ImageData(readFile(img), "", "", 3);
fileList.add(data);
MusicMetadata metadata = (MusicMetadata) src_set.getSimplified();
metadata.setPictureList(fileList);
File dst = new File("destinationPath");
new MyID3().write(src, dst, src_set, metadata);
ジャカルタの正規表現の瓶も必要になります
readFileは、Fileからbyte[]を取得するための関数にすぎません。
public static byte[] readFile (File file) throws IOException {
// Open file
RandomAccessFile f = new RandomAccessFile(file, "r");
try {
// Get and check length
long longlength = f.length();
int length = (int) longlength;
if (length != longlength) throw new IOException("File size >= 2 GB");
// Read file and return data
byte[] data = new byte[length];
f.readFully(data);
return data;
}
finally {
f.close();
}
}
stackOverflowから取得しました。誰からかわかりません:)