我在触摸时正在使用应用程序,它会播放音频。但是10,14次之后,它不起作用,有任何想法吗?
//touch方法
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;
}
});
//播放线程
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);
}
}
};
他们的有可能根据您的问题解决
method-1 简单地可以通过触摸声音覆盖触摸方法。
method-2 您也可以使用可运行的胎面或运行方法
Method-3 在这里我们在触摸视图时运行一个线程,它会检查ISPRESS是否触摸视图
您的解决方案在这里