I am working on application when touch it, it plays audio. But after 10,14 times later it not working, any idea ?
// on touch method
img.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
anim_value = true;
handler.post(runnable);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
anim_value = false;
handler.post(runnable);
}
return true;
}
});
// play inside thread
Runnable runnable = new Runnable() {
@Override
public void run() {
if (anim_value) {
mp = MediaPlayer.create(MainActivity.this,
R.raw.tasbi_tick_tick);
mp.start();
tasbiCounts = (1 + tasbiCounts);
tasbeeh_count.setText(tasbiCounts);
animationTasbeeh.start();
Log.d("AUDIO", "CALL");
} else {
animationTasbeeh.stop();
mp.stop();
mp = MediaPlayer.create(MainActivity.this,
R.raw.tasbi_tick_tick);
}
}
};