MediaPlayback

Provides intents
Provides intent actions: 
Provides intent URIs: 

Plays back media from the MediaStore.

This is the default media player in the current Android SDK 1.0 and is therefore also shipped with the T-mobile G1.

Activity namespace: com.android.music/com.android.music.MediaPlaybackActivity

MediaPlayback

To play back the first audio file in the internal audio content provider, you can use the following code:

Intent i = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
i.setData(u);
startActivity(i);

Comments

hi peli, Intent i1 = new

hi peli,
Intent i1 = new Intent(Intent.ACTION_VIEW);
Uri u1 = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "1");
i1.setData(u1);
startActivity(i1);

does this also call the default video player available in sdk 1.0 and it also comes with g1. I don't know but the same code was working on g1 and now somebody did something to the phone and now its not working. If i want to restore the default video player how can i do so? Does master clear removes all the apps from the from?

Thanks,
Payal

Setting

3 possibilities:
1) In case you have a second video player installed on your phone, probably someone selected the other one as the default player, and your default video player does not show up anymore. -> Go to settings, where you can set the preferred applications and reset that.
2) You don't have the content URI 1 anymore, because someone deleted the video file. Try another number, or check if the video is still installed.
3) You don't have the SD card inserted. Check if other songs play.

Did any of these hints help? Master clear would remove all apps that you have downloaded so far, so I would not recommend that if you can avoid it.

Peli

Hi Peli, The above intent

Hi Peli,
The above intent call MovieView activity from the opensource. So the problem was somehow that activity was removed or got corrupted from g1. When i did Master reset, everything was working fine.

Actually i am making a file browser application. And when user clicks on music file and video file, it should play that file. Now my biggest problem is this intent requires the number of the song or number of video, but how can i find out the number of the song/video?

Can i pass the name of the song/video in some kind of intent to play them?

Thanks,
Payal

I happen to know the answer to this question

I happen to know the answer to this question, because I am also working on a file browser application :-) It will be released soon. What you have to do is to set the correct mime type. Then you can just launch the intent with the file path.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("file:///sdcard/song.mp3");
String type = "audio/mp3";
intent.setDataAndType(data, type);
startActivity(intent);

"type" is the MIME type which you have to set programmatically, depending on the file extension.

I hope this helps.

Peli

Thanks

Thanks a lot Peli,
That really helps.

Payal