【发布时间】: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?
感谢大家的帮助
【问题讨论】:
我在 Google Play 音乐中创建了两个播放列表,但似乎没有找到播放列表。 我正在使用本主题中的代码。
How can I access playlist created by android default music app and call the music app to play it?
感谢大家的帮助
【问题讨论】:
您只能将这些代码用于使用默认 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);
【讨论】: