I made a poject where two audio play using touch with the two different textview.
Here is a simple code for one textview
tv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
if( v == findViewById( R.id.CustomFontText ))
{
if (mp != null && mp.isPlaying()) {
mp.stop();
}
else
{
mp.start();
}
if (mp1 != null && mp1.isPlaying()) {
mp1.pause();
}
mp.start();
}
}
return false;
}
Here mp andmp1 are two media player. tv=textview .When tv touch mp play. and when tv touch again it stop,,,and after stopping if i touch again tv it does not play the audio again.But i want to make it in every touch this within this process….Play -->Stop-->Play-->Stop....continuous…Where i need to fix it or implement it?
First take off this chunk of code…..
Then Every time before starting mp, release the previous one and setDataSource to Music player object, prepare it…
Chnage your code like this…
I think now it wil work for sure…