0

I am using this code to play song with the player that the user would select.

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(ur);
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);

My question is how can i modify this code to pass multiple song paths, so that when the current song is completed the next one can play. I came across this question on SO: Play multiple songs with Android intent and found out that this can't be done. However the last activity has been a year before so i was wondering is there any hack/support that has been developed during this period for doing this?

Please remember that i am not implementing a music player in my app. i'm just passing the music file's uri to the music player on device.

Community
  • 1
  • 1
div
  • 1,475
  • 3
  • 22
  • 32

1 Answers1

0

I am using this code to play song with the default music player.

No, that code invokes the user's chosen activity for handling ACTION_VIEW of an audio/* file: Uri. There are thousands of applications that will advertise activities with a compatible <intent-filter>. This includes dozens, if not hundreds, of "default music player" apps that ship pre-installed on the thousands of Android device models out there.

My question is how can i modify this code to pass multiple song paths, so that when the current song is completed the next one can play.

You delete that code and play the music yourself, using MediaPlayer.

I came across this question on SO... and found out that this can't be done.

Correct.

However the last activity has been a year before so i was wondering is there any hack/support that has been developed during this period for doing this?

No, in part because that "hack/support" would have to work on those thousands of apps.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491