1

I am having trouble searching and playing a song in Google Play Music. Every time Google Play Music opens, it starts playing a radio with the queried song on top of the list. Is there a way to play just the song? Here is my intent:

Intent googleMusic = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);

googleMusic.putExtra(SearchManager.QUERY, query);
googleMusic.putExtra("queryComplete", query);
googleMusic.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,"vnd.android.cursor.item/audio");
googleMusic.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist);
googleMusic.putExtra(MediaStore.EXTRA_MEDIA_TITLE, title);
googleMusic.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, album);

googleMusic.setPackage("com.google.android.music");
googleMusic.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

Now, I would assume that by setting the search mode EXTRA_MEDIA_FOCUS to vnd.android.cursor.item/audio it would search and play just the song, but I feel like I am missing something. If the search mode is not set at all, it would play just the song, however, it won't be the exact match that was queried. For example, searching for "John Legend - All of Me" plays "John Legend - All of Me (Spanish Version)"

Any help is appreciated!

Ivan Mihov
  • 11
  • 2

0 Answers0