I would like to ask, how to write in their own program to call the system's music player it.
I search on Google, mainly there are two ways, but not what I want.
The first is to use the URI of the MP3 music file, and intent, to make the call, but this is used for playback of a song.
/** * Play Songs of the specified name * @param audiopath Specify the music to play by default * /public static void Playaudio (String audiopath) { Intent mintent = new Intent (); Mintent.setaction (Android.content.Intent.ACTION_VIEW); Uri uri = uri.parse ("File:///sdcard/a.mp3"); Replace with audiopath Mintent.setdataandtype (URI, "Audio/mp3"); Intentutil.startintent (mintent); }
This play style effect does not make ugly
The second is to use Compoment to specify Musicbroweractivity, which can only be used for the Android system's own player,
Intent mintent = new Intent (); ComponentName comp = new ComponentName ("Com.android.music", "com.android.music.MusicBrowserActivity"); Mintent.setcomponent (comp); Mintent.setaction (Android.content.Intent.ACTION_VIEW); Startintent (Intent);
I tried it. also configure
Musicbrowseractivity
The third type: Open the system comes with the music player:
Intent Intent = new Intent ("Android.intent.action.MUSIC_PLAYER"); StartActivity (Intent);
Reference post: http://www.eoeandroid.com/thread-293481-1-1.html