【问题标题】:cannot get playlist created in Google Play Music [closed]无法在 Google Play 音乐中创建播放列表 [关闭]
【发布时间】:2014-12-03 11:45:58
【问题描述】:

我在 Google Play 音乐中创建了两个播放列表,但似乎没有找到播放列表。 我正在使用本主题中的代码。

How can I access playlist created by android default music app and call the music app to play it?

感谢大家的帮助

【问题讨论】:

    标签: android playlist


    【解决方案1】:

    您只能将这些代码用于使用默认 Android 媒体存储的音乐播放器。但 Google Play 音乐有自己的数据库。这就是为什么你需要不同的 uri 和列名。

    要获取播放列表列表,我使用以下代码:

    Uri playlistsUri = Uri.parse("content://com.google.android.music.MusicContent/playlists");
    Cursor playlists = context.getContentResolver().query(playlistsUri, new String[]{"_id", "playlist_name"}, null, null, null);
    

    然后您可以在默认的 Android 媒体存储中获取与歌曲 ID 相关的歌曲 ID。之后,您可以直接播放歌曲或获取歌曲详细信息以进行任何操作。

    Uri songsUri = Uri.parse("content://com.google.android.music.MusicContent/playlists/" + playlistId + "/members");
    context.getContentResolver().query(songsUri, new String[]{"SourceId", "hasLocal"}, null, null, null);
    

    要从 Android 上的默认媒体存储中获取歌曲详细信息,您应该使用以下内容:

    Cursor songDetailsCursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    new String[]{MediaStore.Audio.Media.DATA},
                    MediaStore.Audio.Media._ID + " = " + songId,
                    null, null);
    

    【讨论】:

    • 第一次查询只返回一条记录。即最后创建的播放列表。
    猜你喜欢
    • 2013-07-30
    • 2016-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多