android中音乐如何网络获取专辑封面图片

android中音乐如何网络获取专辑封面图片,第1张

该为使用如下代码解析得到:

参考源码中,音乐目录:

packages/apps/Music/src/com/android/music/MusicUtilsjava中函数:getArtwork(context, song_id, album_id, true)

public static Bitmap getArtwork(Context context, long song_id, long album_id,

boolean allowdefault) {

if (album_id < 0) {

// This is something that is not in the database, so get the album art directly

// from the file

if (song_id >= 0) {

Bitmap bm = getArtworkFromFile(context, song_id, -1);

if (bm != null) {

return bm;

}

}

if (allowdefault) {

return getDefaultArtwork(context);

}

return null;

}

ContentResolver res = contextgetContentResolver();

Uri uri = ContentUriswithAppendedId(sArtworkUri, album_id);

if (uri != null) {

InputStream in = null;

try {

in = resopenInputStream(uri);

return BitmapFactorydecodeStream(in, null, sBitmapOptions);

} catch (FileNotFoundException ex) {

// The album art thumbnail does not actually exist Maybe the user deleted it, or

// maybe it never existed to begin with

Bitmap bm = getArtworkFromFile(context, song_id, album_id);

if (bm != null) {

if (bmgetConfig() == null) {

bm = bmcopy(BitmapConfigRGB_565, false);

if (bm == null && allowdefault) {

return getDefaultArtwork(context);

}

}

} else if (allowdefault) {

bm = getDefaultArtwork(context);

}

return bm;

} finally {

try {

if (in != null) {

inclose();

}

} catch (IOException ex) {

}

}

}

return null;

}

private static Bitmap getArtworkFromFile(Context context, long songid, long albumid) {

Bitmap bm = null;

byte [] art = null;

String path = null;

if (albumid < 0 && songid < 0) {

throw new IllegalArgumentException("Must specify an album or a song id");

}

try {

if (albumid < 0) {

Uri uri = Uriparse("content://media/external/audio/media/" + songid + "/albumart");

ParcelFileDescriptor pfd = contextgetContentResolver()openFileDescriptor(uri, "r");

if (pfd != null) {

FileDescriptor fd = pfdgetFileDescriptor();

bm = BitmapFactorydecodeFileDescriptor(fd);

}

} else {

Uri uri = ContentUriswithAppendedId(sArtworkUri, albumid);

ParcelFileDescriptor pfd = contextgetContentResolver()openFileDescriptor(uri, "r");

if (pfd != null) {

FileDescriptor fd = pfdgetFileDescriptor();

bm = BitmapFactorydecodeFileDescriptor(fd);

}

}

} catch (FileNotFoundException ex) {

}

if (bm != null) {

mCachedBit = bm;

}

return bm;

}

private static Bitmap getDefaultArtwork(Context context) {

BitmapFactoryOptions opts = new BitmapFactoryOptions();

optsinPreferredConfig = BitmapConfigRGB_565;

return BitmapFactorydecodeStream(

contextgetResources()openRawResource(Rdrawableplay_img_default), null, opts);

}

private static final Uri sArtworkUri = Uriparse("content://media/external/audio/albumart");

private static final BitmapFactoryOptions sBitmapOptions = new BitmapFactoryOptions();

private static Bitmap mCachedBit = null;

获取cursor:

myCur = getContentResolver()query(

MediaStoreAudioMediaEXTERNAL_CONTENT_URI,

new String[] { MediaStoreAudioMediaTITLE,

MediaStoreAudioMediaDURATION,

MediaStoreAudioMediaARTIST,

MediaStoreAudioMedia_ID,

MediaStoreAudioMediaALBUM,

MediaStoreAudioMediaDISPLAY_NAME,

MediaStoreAudioMediaDATA,

MediaStoreAudioMediaALBUM_ID}, null,null, null);

myCurmoveToPosition(position);

设置专辑封面

long songid = myCurgetLong(3);

long albumid = myCurgetLong(7);

Bitmap bm = MusicUtilsgetArtwork(this, songid, albumid,true);

if(bm != null){

Logd(TAG,"bm is not null==========================");

playImgsetImageBitmap(bm);

}else{

Logd(TAG,"bm is null============================");

}

你好!楼主!

转存歌曲封面很简单,选择歌曲信息,最后一栏封面选项,可以查看到封面,右键点击,选择复制,然后可以随意粘贴到任何你想保持的位置!

简单的来说就像平时我们从网上下载一样,复制,粘贴,保存到桌面,或者其他地方!

点击下载:点击即可下载,歌曲合集包!

歌曲排行:《万疆》《放空》《 New boy 》《星辰大海》《来迟》《自月光与朱砂痣》《目及皆是你》《气象站台》《别错过》《解药》《TA》《落日与晚风》《大风吹》《失眠的夜》《潮汐》《目娱自乐》《奔赴星空》《let me down slowly》《慢热》《执迷不悟》《错位时空》《金玉良缘》《雾里》《STAY》《银河与星斗》《叹》《四季予你》《怕来者不是你》《热爱105C的你》《骁》《Ring Ring Ring 》《时光背面的我》《我想要》《时光洪流》《不如》《执迷不悟》《你的眼睛像星星》《穷叉叉》《海底》《你头顶的风》《自愈》《一路生花》《我们俩》《南半球与北海道》《茫》《假面舞会》《百年孤寂》

车载音乐打包、经典老歌100首热度排行:

1 真的好想你 (周冰倩) 2 梦里共醉 (梅艳芳) 3 傻瓜 (苏慧伦)

4 爱 (小虎队) 5 海阔天空 (beyond) 6 上海滩 (叶丽仪)

7 谁的眼泪在飞 (孟庭苇) 8 梅花三弄 (姜育恒) 9 大海 (张雨生)

10 送别 (蔡琴) 11 飘雪 (陈慧娴) 12 感恩的心 (欧阳菲菲)

13 是你给我一片天 (成龙) 14 心雨 (高胜美) 15 情人 (杜德伟)

16 胭脂扣 (梅艳芳) 17 敖包相会 (蔡琴) 18 吻别 (张学友)

22 朋友 (谭咏麟) 23 爱你 (郭富城) 24 一剪梅 (张明敏)

25 爱我的人和我爱的人 (裘海正) 26 没有情人的情人节 (孟庭苇) 27 涟漪 (陈百强)

28 明天会更好 (罗大佑) 29 永远爱着你 (草蜢) 30 回家 (顺子)

31 梁祝 (吴奇隆) 32 浪人情歌 (伍佰) 33 你的样子 (罗大佑)

34 红日 (李克勤) 35 屋顶 (吴宗宪) 36 样样红 (黄安)

37 女人花 (梅艳芳) 38 朋友别哭 (吕方) 39 昨日重现 (高胜美)

40 最浪漫的事 (赵咏华) 41 爱要怎么说出口 (赵传) 42 七天七世纪 (李天华)

43 我是真的爱你 (张信哲) 44 相逢在雨中 (黎明) 45 精忠报国 (屠洪刚)

46 爱如潮水 (张信哲) 47 挪威的森林 (伍佰) 48 留恋 (陈慧娴)

49 回家 (王杰) 50 情人 (beyond) 51 大约在冬季 (齐秦)

52 祝你一路顺风 (吴奇隆) 53 谢谢你的爱 (刘德华) 54 铁血丹心 (罗文)

55 千千阙歌 (陈慧娴) 56 别怕我伤心 (张信哲) 57 听说爱情回来过 (林忆莲)

58 一千个伤心的理由 (张学友) 59 白月光 (张信哲) 60 知心爱人 (付笛生/任静)

61 讲不出再见 (谭咏麟) 62 追梦人 (凤飞飞) 63 如果这都不算爱 (张学友)

64 一生爱你千百回 (梅艳芳) 65 窗外 (李琛) 66 童年 (蔡国权)

67 童年 (罗大佑) 68 宝贝对不起 (草蜢) 69 你怎么舍得我难过 (黄品源)

70 我恨我痴心 (刘德华) 71 相思风雨中 (张学友/汤宝如) 72 情书 (张学友)

73 喜欢你 (beyond) 74 祝福 (张学友) 75 大地 (beyond)

用最简单的QQ音乐就可以下载专辑封面

就算那首歌没有专辑封面也可以下载到歌手

选定某一首歌的时候

下载时候会提示是否下载专辑封面

把那个小钩钩打上

就可以下载专辑封面了

以上就是关于android中音乐如何网络获取专辑封面图片全部的内容,包括:android中音乐如何网络获取专辑封面图片、如何导出MP3歌曲文件专辑封面、哪里下载的歌曲有歌曲专辑封面等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9796177.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-02
下一篇2023-05-02

发表评论

登录后才能评论

评论列表(0条)

    保存