Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay A Random Sound onTouch
    primarykey
    data
    text
    <p>I'm trying to play a random sound onTouch event (currently working), but the sound is actually played twice onTouch event instead of once as intended. I'm assuming this is due to the UP and Down onTouch event. Any thoughts?</p> <p>NOTE: I commented out the additional random sound files while testing.</p> <pre><code>package com.tmapps.wiub; import java.util.Random; import com.tmapps.wiub.SoundManager; import android.app.Activity; import android.os.Bundle; import android.view.MotionEvent; import android.view.Window; import android.view.WindowManager; public class Soundboard extends Activity { private SoundManager mSoundManager; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FULLSCREEN CODE requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); mSoundManager = new SoundManager(); mSoundManager.initSounds(getBaseContext()); mSoundManager.addSound(0, R.raw.sound0); // COMMENTED OUT WHILE TESTING // mSoundManager.addSound(1, R.raw.sound1); // mSoundManager.addSound(2, R.raw.sound2); // mSoundManager.addSound(3, R.raw.sound3); // mSoundManager.addSound(4, R.raw.sound4); // mSoundManager.addSound(5, R.raw.sound5); // mSoundManager.addSound(6, R.raw.sound6); // mSoundManager.addSound(7, R.raw.sound7); // mSoundManager.addSound(8, R.raw.sound8); // mSoundManager.addSound(9, R.raw.sound9); }; Random r = new Random(); int x = r.nextInt(1); switch (evt.getAction()) { case MotionEvent.ACTION_DOWN: mSoundManager.playSound(x); return super.onTouchEvent(evt); case MotionEvent.ACTION_UP: break; default: break; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload