正在开发一款音乐播放器,刚好完毕。但是为了让界面更好看点,所以想把歌手的专辑海报图片作为背景,api中好像这方面的函数,但是我看到某些播放器,有这个功能,手机自带的播放器就有,不知道从何下手 !!谢谢!!!指定下~~~~~~~~~~
解决方案 »
- Android下Cookie的问题,求帮助
- 初学者问题:android+sqlite查询报错
- android平台创建数据库的问题。。。
- android的listView有滚动条时(即实际Item数比显示出来的Item数多),点击item变色事件报空指针错
- 怎么让一个进程退出前台的时候 自动销毁
- 自定义ViewGroup与ScrollView 不能共存?
- 求助:gridview和checkbox结合使用的问题
- ScrollView嵌套GridView问题
- CoordinatorLayout 导致布偶尔局乱掉
- 大神助我
- 有个师兄让我参加他的项目,但是我不知道是否我能胜任?想让大家参考下
- 避免onDraw(Canvas canvas)的重复性画图,急啊!
private static final BitmapFactory.Options sBitmapOptionsCache = new BitmapFactory.Options();
sBitmapOptionsCache.inPreferredConfig = Bitmap.Config.RGB_565;
sBitmapOptionsCache.inDither = false;
static HashMap<Integer, SoftReference<Bitmap>> sAlbumArtCache = new HashMap<Integer, SoftReference<Bitmap>>(
100, 0.85f); // Get album art for specified album. This method will not try to
// fall back to getting artwork directly from the file, nor will
// it attempt to repair the database.
public static Bitmap getArtworkQuick(Context context, int album_id, int w,
int h) {
// NOTE: There is in fact a 1 pixel border on the right side in the
// ImageView used to display this drawable. Take it into account now, so
// we don't
// have to scale later.
if (sAlbumArtCache.containsKey(album_id)) {
SoftReference<Bitmap> albumArt = sAlbumArtCache.get(album_id);
Bitmap bitmap = albumArt.get();
if (bitmap != null) {
return bitmap;
} else {
sAlbumArtCache.remove(album_id);
Log.d("Music", "getArtworkQuick(): no Bitmap for " + album_id);
}
}// else {
// Log.d("Music", "getArtworkQuick(): no cache for " + album_id);
// } w -= 1;
ContentResolver res = context.getContentResolver();
Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
if (uri != null) {
ParcelFileDescriptor fd = null;
try {
fd = res.openFileDescriptor(uri, "r");
int sampleSize = 1; // Compute the closest power-of-two scale factor
// and pass that to sBitmapOptionsCache.inSampleSize, which will
// result in faster decoding and better quality
sBitmapOptionsCache.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(),
null, sBitmapOptionsCache); int nextWidth = sBitmapOptionsCache.outWidth >> 1;
int nextHeight = sBitmapOptionsCache.outHeight >> 1;
while (nextWidth > w && nextHeight > h) {
sampleSize <<= 1;
nextWidth >>= 1;
nextHeight >>= 1;
} sBitmapOptionsCache.inSampleSize = sampleSize;
sBitmapOptionsCache.inJustDecodeBounds = false;
Bitmap b = BitmapFactory.decodeFileDescriptor(
fd.getFileDescriptor(), null, sBitmapOptionsCache); if (b != null) {
// finally rescale to exactly the size we need
// if (sBitmapOptionsCache.outWidth != w
// || sBitmapOptionsCache.outHeight != h) {
// Bitmap temp = b;
// b = Bitmap.createScaledBitmap(b, w, h, false);
// temp.recycle();
// } sAlbumArtCache.put(album_id, new SoftReference<Bitmap>(b));
} return b;
} catch (FileNotFoundException e) { } finally {
try {
if (fd != null)
fd.close();
} catch (IOException e) {
}
}
}
return null;
}android的opencore这一块是不支持wma文件的,如果你想取到wma文件的专辑封面,可以参考http://download.csdn.net/detail/dazme886/3638064