显示在Android系统的默认媒体播放器的图像 [英] Display an image in Default media player of android

查看:123
本文介绍了显示在Android系统的默认媒体播放器的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的code,首先我recoreded音频文件,并开始播放。对于在播放音频文件

Here is my code, First i recoreded an audio file and started playing it . For playing the audio file

/**
 * 
 * play the recorded audio
 *
 */
    public void playAudio() {
    try {

        Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
        Uri data = Uri.parse(path);
        intent.setDataAndType(data, "audio/mp3");
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        // TODO: handle exception
    }
    }

和输出中被调用设备的默认媒体播放器......在这里,我需要显示在媒体播放器中的专辑图片的地方的图像..请帮助..

and the ouput is calling the default media player of device... Here i need to show an image in that media player in the place of album image.. Pls help..

我附上了image..thats我需要的..

I have attached an image..thats what i needed..

推荐答案

用下面的code检索歌曲的专辑封面的默认媒体播放器。

The default media player is using the following code to retrieve the album art of a song.

Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
ContentResolver res = context.getContentResolver();
InputStream in = res.openInputStream(uri);
Bitmap artwork = BitmapFactory.decodeStream(in);

在这里album_id是歌曲的albumd ID。因此,为了表现出专辑封面的默认播放器应该知道的相册ID,并检查是否有与此ID相关联的专辑封面。所以,如果你想展示的艺术作品,你必须插入Android的数据库文件,然后从那里玩。

where album_id is the albumd id of the song. So in order to show an album art the default player should know the album id and check if there is album art associated with this id. So if you want to show artwork you have to insert your file in android's database and then play it from there.

这篇关于显示在Android系统的默认媒体播放器的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆