如何使用MediaStore获取音频文件的缩略图 [英] How to get thumbnails of audio files by using MediaStore

查看:31
本文介绍了如何使用MediaStore获取音频文件的缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在开发一个简单的音乐播放器,我需要获取所有音频文件的缩略图。

String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";

    String[] projection = {
            MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.DISPLAY_NAME,
            MediaStore.Audio.Media.DURATION,
            MediaStore.Audio.Media.YEAR
    };
    cursor = getBaseContext().getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            projection, selection, null, null);
    while(cursor.moveToNext()) {

        name.add(cursor.getString(4));
        path.add(cursor.getString(3));
        duration.add(cursor.getString(5));
    }

我怎样才能得到它?提前谢谢。

推荐答案

您可能想看看answer我在类似问题上给出的这个。您需要提供歌曲的Uri才能打开封面。

这篇关于如何使用MediaStore获取音频文件的缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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