Android Call Music player, three kinds of parties

Source: Internet
Author: User




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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.