因此,我正在尝试获取专辑封面的模糊版本并将其显示在imageview中。 这行得通。
这是我的代码
private void loadAlbumArt(){
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri albumArtUri = ContentUris.withAppendedId(sArtworkUri, songList.get(songIndex).getAlbumID());
int[] myImageList = new int[]{R.drawable.image1, R.drawable.image2, R.drawable.image3,
R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7 };
Random random = new Random();
int randomNumber = random.nextInt(myImageList.length);
mAlbumArtLarge.setImageURI(albumArtUri);
//Get the bitmap from the ImageView.
Bitmap bitmap = ((BitmapDrawable) mAlbumArtLarge.getDrawable()).getBitmap();
//Let's apply Gaussian blur effect with radius "10.5" and set to ImageView.
mAlbumArtLarge.setImageBitmap(new BlurUtil().blur(MainActivity.this, bitmap, 10.5f));
}
mAlbumArtLarge 显示模糊的专辑封面,但是当没有专辑封面时,如何在myImageList中随机显示其中一张图像?
谢谢