首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在我的android应用程序中使用下载的Google Play Store音乐?

问如何在我的android应用程序中使用下载的Google Play Store音乐?
EN

Stack Overflow用户
提问于 2015-12-13 08:59:11
回答 1查看 57关注 0票数 0

我正在写一个简单的应用程序来检测和打印用户在他们的设备上的所有歌曲。但是,该应用程序无法找到通过Google Play Store下载/购买的任何歌曲。如果我转到Play music应用程序,我可以看到音乐,但我的应用程序在打印歌曲列表时会忽略这些歌曲。我尝试了我能在这里找到的其他解决方案,但我不能让它们中的任何一个为我工作。

被注释掉的URI行使应用程序在打开时崩溃,如果我使用它,尽管这似乎是其他答案提出的。以下是代码的相关部分:

代码语言:javascript
复制
public void getSongList() {
    ContentResolver musicResolver = getContentResolver();
    Uri musicUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    //Uri musicUri = Uri.parse("content://com.google.android.music.MusicContent/audio");

    Cursor musicCursor = musicResolver.query(musicUri, null, null, null, null);
    if(musicCursor!=null && musicCursor.moveToFirst()){
        //get columns
        int titleColumn = musicCursor.getColumnIndex
                (android.provider.MediaStore.Audio.Media.TITLE);
        int idColumn = musicCursor.getColumnIndex
                (android.provider.MediaStore.Audio.Media._ID);
        int artistColumn = musicCursor.getColumnIndex
                (android.provider.MediaStore.Audio.Media.ARTIST);
        //add songs to list
        do {
            long thisId = musicCursor.getLong(idColumn);
            String thisTitle = musicCursor.getString(titleColumn);
            String thisArtist = musicCursor.getString(artistColumn);
            songList.add(new Song(thisId, thisTitle, thisArtist));
        }
        while (musicCursor.moveToNext());
    }
    assert musicCursor != null;
    musicCursor.close();

}

谢谢,请记住,我对应用程序开发是相当陌生的。

EN

回答 1

Stack Overflow用户

发布于 2015-12-13 09:34:24

Google Play music不允许第三方应用程序通过任何API访问其音乐--您可以期望的唯一音乐是本地存储的音乐。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34246854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档