2011年5月17日火曜日

AndroidStudyMemo=Searching for Multimedia

 

You can use the search intent called android.intent.action.MEDIA_SEARCH to search

for multimedia on a given device.You can also register an intent filter with your application

to show up as a source for multimedia with this action. For example, you could perform

a search for a specific artist and song like this:

 

              Intent searchMusic = new Intent(

                            android.provider.MediaStore.INTENT_ACTION_MEDIA_SEARCH);

              searchMusic.putExtra(android.provider.MediaStore.EXTRA_MEDIA_ARTIST,

                            "Cyndi Lauper");

              searchMusic.putExtra(android.provider.MediaStore.EXTRA_MEDIA_TITLE,

                            "I Drove All Night");

              searchMusic.putExtra(android.provider.MediaStore.EXTRA_MEDIA_FOCUS,

                            "audio/*");

              startActivity(searchMusic);

 

If you load up a bunch of music on your device (such as Cyndi Lauper's "I Drove All

Night") and launch this intent, you are then directed straight to the song you requested.

Note that if you have many music apps installed, you might need to select an appropriate

one (such as the Music application) the first time you send the Intent.

 

0 件のコメント:

コメントを投稿