Is there a way to play a media with the default media player. I can do with the following code
Intent intent = new Intent(Intent.ACTION_VIEW);
MimeTypeMap mime = MimeTypeMap.getSingleton();
String type = mime.getMimeTypeFromExtension("mp3");
intent.setDataAndType(Uri.fromFile(new File(songPath.toString())), type);
startActivity(intent);
But this launches a player with less controls and can't push it to the background. Can I launch the player with the default media player?
Thx! Rahul.
Try the below code:::
Updated:: Try this also
I've been researching this for the last few days as I don't have the stock music player. It seems so tragic that it can't be done easily. After looking through various music app's AndroidManifest.xml for clues I stumbled upon MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.
Using the below method I'm able to start the Samsung music player in the background as long as the song is in the Android MediaStore. You can specify Artist, Album or Title. This method also works for Google Play Music but unfortunately even the newest version of the stock Android player does not have this intent:
https://github.com/android/platform_packages_apps_music/blob/master/AndroidManifest.xml
It would be nice to find a solution that uses a content URI or URL but this solution works for my application.