Regarding Playing Music via Spinner in android
I have created a spinner view with some set of lists include. Now i wanted to pl开发者_JAVA技巧ay music while selecting those item list one by one....any idea....
hi raghavan you can use this...
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("file://"+Environment.getExternalStorageDirectory()
.getAbsolutePath()+"/" + fileName);
String type = "audio/mp3";
intent.setDataAndType(data, type);
startActivity(intent);
and in the filename variable pass the filename that you have selected in the list. Hope this helps....
edit #1
final MediaPlayer mPlayer=MediaPlayer.create(getBaseContext(), R.raw.reload);
mPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
//new Toast(getBaseContext());
mPlayer.release();
mPlayer = null;
}
});
Insert this code inside your itemselect event...
精彩评论