سلام من از این کد برای تکرار صدا تا زمان برداشتن انگشت و لمس دکمه بدون برداشتن انگشت و صدا دادن اونا استفاده کرده ام
کد HTML:
// Create a new button and place it into a table row
LinearLayout lnr = (LinearLayout) findViewById(R.id.tableRow3);
Button b1 = new Button(this);
lnr.addView(b1);
// Associate the event
b1.setOnTouchListener(new OnTouchListener() {
MediaPlayer mp = new MediaPlayer();
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// Finger started pressing --> play sound in loop mode
try {
FileInputStream fileInputStream = new FileInputStream( PATH );
mp.setDataSource(fileInputStream.getFD());
mp.prepare();
mp.setLooping(true);
mp.start();
} catch (Exception e) {}
break;
case MotionEvent.ACTION_UP:
// Finger released --> stop playback
try {
mp.stop();
mp.reset();
} catch (Exception e) {}
break;
}
return true;
}
});
فقط این قسمتش رو متوجه نشدم PATH توی اکلیپس اروور میده کسی هست راهنمایی کنه ممنون میشم؟؟؟