我正在改变ID3标签,在音频文件中的元数据,如:
I am working to change ID3 tags, the metadata in audio files, such as:
艺术家 标题 专辑 等和核心点,。该编辑ID3标签应该只显示到我的应用程序。
And the core point,. that edited ID3 tags should be shown only into my app.
我想这是你在找什么的的 MyID3库 设置和获取标签的媒体文件。
I think this is what you are looking for MyID3 library to set and get tags for media file.
下载这个jar文件的 MyID3_for_android 并把它添加到你的项目的构建路径。
这里是样本code。这里 pathdata 是音频文件的文件路径。
Download this jar file MyID3_for_android and add it to your project's build path.
here is the sample code. here pathdata
is the file path of the audio file.
File src = new File(pathdata);
MusicMetadataSet src_set = null;
try {
src_set = new MyID3().read(src);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // read metadata
if (src_set == null) // perhaps no metadata
{
Log.i("NULL", "NULL");
}
else
{
try{
IMusicMetadata metadata = src_set.getSimplified();
String artist = metadata.getArtist();
String album = metadata.getAlbum();
String song_title = metadata.getSongTitle();
Number track_number = metadata.getTrackNumber();
Log.i("artist", artist);
Log.i("album", album);
}catch (Exception e) {
e.printStackTrace();
}
File dst = new File(pathdata);
MusicMetadata meta = new MusicMetadata("name");
meta.setAlbum("Chirag");
meta.setArtist("CS");
try {
new MyID3().write(src, dst, src_set, meta);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ID3WriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // write updated metadata
}
编码快乐:)
Happy Coding :)