admin管理员组文章数量:1794759
android代码修改mp3文件封面,android
我正在尝试从音频文件Uri中获取专辑封面,这是我的代码:
// uri is the audio file uri
public static Bitmap getSongCoverArt(Context context, Uri uri){
Bitmap songCoverArt = null;
String[] projections = {MediaStore.Audio.Media.ALBUM_ID};
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, projections, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID);
cursor.moveToFirst();
Uri songCover = Uri.parse("content://media/external/audio/albumart");
Uri uriSongCover = ContentUris.withAppendedId(songCover, column_index);
Log.d(TAG, uriSongCover.toString());
ContentResolver res = context.getContentResolver();
try {
InputStream in = res.openInputStream(uriSongCover);
songCoverArt = BitmapFactory.decodeStream(in);
}catch (FileNotFoundException e){
Log.e(TAG, e.getMessage());
}
}finally {
if(cursor != null){
cursor.close();
}
}
return songCoverArt;
}
此函数始终返回“对于content:// media / external / audio / albumart / 0没有条目”
本文标签: android代码修改mp3文件封面android
版权声明:本文标题:android代码修改mp3文件封面,android 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1700122033a402222.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论