播放带动画的音频
play audio with animation
我正在处理应用程序,当触摸它时,它会播放音频。但是在 10,14 次之后它不起作用,知道吗?
//触摸方法
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 你也可以使用运行nable tread 或者运行 method
method-3 这里我们 运行 一个线程,每当你触摸视图时,它检查 isPress 与否,如果视图被触摸,那么声音会重复,直到你松开通过触摸查看。
你的解决方案here
我正在处理应用程序,当触摸它时,它会播放音频。但是在 10,14 次之后它不起作用,知道吗?
//触摸方法
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 你也可以使用运行nable tread 或者运行 method
method-3 这里我们 运行 一个线程,每当你触摸视图时,它检查 isPress 与否,如果视图被触摸,那么声音会重复,直到你松开通过触摸查看。
你的解决方案here