簡體   English   中英

如何在我的Android應用中使用下載的Google Play商店音樂?

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

我正在編寫一個簡單的應用程序,以檢測和打印用戶在其設備上擁有的所有歌曲。 但是,該應用程序找不到通過Google Play商店下載/購買的任何歌曲。 如果我轉到Play音樂應用,可以看到音樂,但是在打印歌曲列表時,我的應用會忽略這些歌曲。 我嘗試了在這里可以找到的其他解決方案,但是我無法為他們工作。

如果我改為使用注釋掉的URI行,則在打開應用程序時該應用程序將崩潰,盡管這似乎是其他答案的建議。 這是代碼的相關部分:

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

}

謝謝,請記住,我是應用程序開發的新手。

Google Play音樂不允許第三方應用程序通過任何API訪問其音樂-您可以期望的唯一音樂是本地存儲的音樂。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM