简体   繁体   English

如何在我的Android应用中使用下载的Google Play商店音乐?

[英]How do I use downloaded Google Play Store music in my android app?

I'm writing a simple app to detect and print all songs the user has on their device. 我正在编写一个简单的应用程序,以检测和打印用户在其设备上拥有的所有歌曲。 However, the app cannot find any songs that have been downloaded/purchased through the Google Play Store. 但是,该应用程序找不到通过Google Play商店下载/购买的任何歌曲。 I can see the music if I go to the Play Music app, but my app omits those songs when it prints the song list. 如果我转到Play音乐应用,可以看到音乐,但是在打印歌曲列表时,我的应用会忽略这些歌曲。 I tried the other solutions I could find on here, but I couldn't get any of them to work for me. 我尝试了在这里可以找到的其他解决方案,但是我无法为他们工作。

The commented out URI line makes the app crash when opened if I use it instead, though this seemed to be what other answers proposed. 如果我改为使用注释掉的URI行,则在打开应用程序时该应用程序将崩溃,尽管这似乎是其他答案的建议。 Here is the relevant part of the code: 这是代码的相关部分:

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();

}

Thank you, please keep in mind I'm fairly new to app development. 谢谢,请记住,我是应用程序开发的新手。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为 Google Play 商店签署我的 flutter 应用程序? - How do I sign my flutter app for google play store? 如何在Android上访问Google Play音乐库? - How do I get access to a Google Play Music library on Android? 如何在我的应用程序中使用Google Play游戏? - How do I use Google Play Games in my app? 如何使我的Android应用程序播放手机音乐播放器中的音乐? - how do i make my android application play music from the phone's music player? 如何检测Google Play商店是否正在下载/安装特定应用? - How to detect if a specific app is being downloaded/installed by the Google Play store? 如何在Google Play商店网站上跟踪我的Android应用与下载的展示次数? - How can I track impressions of my android app vs downloads on Google Play Store Website? 如何将下载的文件保存到我的应用程序中以供以后使用? - How do I save downloaded files to my app for later use? 我如何在 google Play 商店上发布我现有 ionic 应用程序的更新版本? - How do i publish an updated version of my existing ionic app on google play store? 如何从我的 PhoneGap/Cordova 应用程序直接导航到 Google Play 商店中的应用程序? - How do I navigate directly to an app in the Google Play Store from my PhoneGap/Cordova application? 即使不是使用Play应用下载的,Android也会将崩溃/冻结报告发送到Google的Play商店吗? - Does Android send crash/freeze reports to Google's Play Store even if the app was not downloaded using the Play app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM