I want to use default music player in my app. Scenario is,if someone click on the song in the playlist it should be automatically play with default music player of android.
public void defaultMusic(View v) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(String.valueOf(R.raw.sample_audio));
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
}
But error is coming "Couldn't play the track you requested."