eclipse - Sound played after small delay in Android App -


Text after "

I use several buttons in my app and many small songs to play like piano etc.

but use Taxes, under the code given below, when the app plays a song, there is a delay of about about half a second between pressing the button and playing a sound.

How can I fix this?

  The public class increases the main activity activity (MediaPlayer mp; @ Override Protected Zero to Create (Bundle Saved Instantstate) {Super.New (Saved Instantstate); setContentView (R.layout Activity_main; setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); GetWindow () setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN). Find the last button g1 = (button) ViewById (R.id.bu1); last button g2 = ( Button) Find VVBID (R.DD.B2); last button g3 = (button) Find VVBIID (R.B.B. 3 ); Find the last button g4 = (button) VVBiID (RID.BU4); last button g5 = (button) Find VVBIID (R.B. 5); g1.setOnTouchListener (New OnTouchListener () {MediaPlayer mp = MediaPlayer.create (MainActivity.this, R.raw.closehh); @Override Public Boolean onTouch (see, MotionEvent motionevent) {int action = motionevent.getAction (); if (action == MotionEvent.ACTION_DOWN) { Mp.start (); mp.seekTo (0); g1.setBackgroundResource (R.drawable.a0005z);} if (action == MotionEvent.ACTION_UP) {g1.setBackgroundResource (R) Drawable.a0005);} Return false;}}); G2.setOnTouchListener (New OnTouchListener) {MediaPlayer mp = MediaPlayer.create (MainActivity.this, R.raw.openhh); @Override Public Boolean OnTouch (see, MotionEvent motionevent) {int action = motionevent.getAction () ; If (action == MotionEvent.ACTION_DOWN) {mp.start (); mp.seekTo (0); g2.setBackgroundResource (R.drawable.a0005z);} if (action == MotionEvent.ACTION_UP) {g2.setBackgroundResource ( R Drawable.a0005);} Return false;}});  

There is low latency playback of class sound resources. It uses the media player, but loads in memory for more sensitive playback


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -