在Android中查询Google Play音乐数据库

Ama*_*shi 12 android android-contentprovider

我正在尝试查询由"Google Play音乐"应用创建的播放列表,但尚未能够这样做.我使用本地存储的内容创建了一个播放列表.我使用以下代码来查询:

Cursor c = managedQuery(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                                       new String[] {MediaStore.Audio.Playlists._ID,
                                                     MediaStore.Audio.Playlists.NAME
                                                    }, null, null, null);
Run Code Online (Sandbox Code Playgroud)

这适用于Winamp,但不适用于Google Play音乐.事实上,Winamp不会显示使用Google Play音乐创建的播放列表.但是,Google Play音乐会显示使用Winamp创建的播放列表.我的猜测是,Google Play音乐正在使用自己的数据库来存储播放列表,其他播放器使用内容提供商和uri MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI来存储播放列表.有没有办法让Google Play音乐创建播放列表?

jdg*_*day 14

我知道这个帖子已经老了,但我也一直在努力解决这个问题.

Google Play音乐会根据此非标准内容URI公开其播放列表

// list all playlists with their ID and Name
Cursor cursor = getContentResolver().query(
    "content://com.google.android.music.MusicContent/playlists", 
    new String[] {"_id", "playlist_name" }, 
    null, null, null);
Run Code Online (Sandbox Code Playgroud)

Google Play音乐内容提供商使用以下列名称

  • isAllLocal
  • playlist_owner_name
  • hasLocal
  • hasRemote
  • hasAny
  • KeepOnId
  • playlist_art_url
  • playlist_share_token
  • _ID
  • _计数
  • playlist_owner_profile_photo_url
  • keeponSongCount
  • playlist_description
  • playlist_type
  • PLAYLIST_ID
  • keeponDownloadedSongCount
  • PLAYLIST_NAME

如果没有这个真正有用的应用内容提供商助手,我绝不会想到这一点

  • @Chrizzor,如果为查询的第二个参数传递null(而不是传递列的列表),结果将包含所有列.然后你可以检查光标的值(它有一个属性为mColors的mCursor属性)来查看所有的列名.我在这里列出它们,但其中有47个! (2认同)

小智 0

\xc3\x8e 尝试查询 ContenProvider,就像启动 google Music 应用程序时在 Logcat 中看到的那样:

\n\n

getContentResolver().query(Uri.parse("content://com.google.android.music.MusicContent/playlists"), null, null, null, null);

\n\n

但我没有得到结果:-(也许我做错了,之前与内容提供者没有太多合作,或者内容提供者可能对其他应用程序不公开。

\n

  • 这实际上对我有用,只是做了一个小小的改变。我没有使用“null”投影,而是使用了 {MediaStore.Audio.Playlists.NAME, MediaStore.Audio.Playlists._ID}。我只需要播放列表的 ID 和名称。所以,这满足了我的需要。 (2认同)