我正在尝试在 Spotify 应用程序中播放已知的播放列表。我最好的方法是加载播放列表,但不播放它。
我尝试过两件事。首先从搜索开始播放:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.music",
"com.spotify.music.MainActivity"));
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE);
intent.putExtra(MediaStore.EXTRA_MEDIA_PLAYLIST, <PLAYLIST>);
intent.putExtra(SearchManager.QUERY, <PLAYLIST>);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
我尝试将 PLAYLIST 替换为已知播放列表的名称。还尝试了“4Rj0zQ0Ux47upeqVSIuBx9”、“spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9”等。所有这些都是对这些字符串的搜索失败。
第二次尝试是查看意图:
String uri = "https://play.spotify.com/user/11158272501/playlist/4Rj0zQ0Ux47upeqVSIuBx9";
Intent intent= new Intent( Intent.ACTION_VIEW, Uri.parse(uri) );
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
这会加载播放列表,但不会播放。如果我然后使用多种方法之一发送 KEYCODE_MEDIA_PLAY 键,它只会恢复当前播放列表,而不是这个新加载的列表。
有任何人(包括 Spotify 开发人员)提供帮助吗?
顺便说一句,我不想使用 Spotify SDK 来实现我自己的 Spotify 播放器 - 当用户设备上已经安装了一个完美的播放器时,不得不这样做似乎很遗憾。