hi i have created a new mp3 player app for my owm. In that i am playing songs from a folder where its been stored, the problem is when one song is in play and when i click the next song both gets played, i want the other one to be stopped. the following is my code
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
{
Log.e("", "aaaaa "+arg2);
if(arg2==0)
{
mplayer = MediaPlayer.create(aply.this, R.raw.a);
mplayer.start();
}
else
{
mplayer = MediaPlayer.create(aply.this, R.raw.download);
mplayer.start();
}
mplayer.start();
}
});
pls help me in this....
you can check the playing status, if it is playing you have to stop the player and reset the contents and issue the command Play.
if (mplayer.isPlaying()) {
mp.stop();
}
mplayer.reset();
mplayer.setDataSource(abs_filepath);//set the path
mplayer.prepare();
mplayer.start();
above a sample code