获得一些日蚀的音频文件没有问题: 当按下机器屏幕上的按钮和机器屏幕上的按钮时, java 要正确播放一些音频文件: java 。 但是, 我试图做的程序是一个制动器工作室, 您只能如此快速地按下按钮 。 在紧接前( 大约 5 秒) 按下同一按钮之后, 您可以按下按钮来点音频样本, 时间稍有延迟 。 显然, 这在能够按下指定时间的按钮时会给音乐程序带来问题 。 任何关于我如何用应用程序快速按下按钮的建议都非常重要?
package studio.music;
import android.app.Activity;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class StudioActivity extends Activity implements OnClickListener{
MediaPlayer mp1,mp2;
Button button_one,button_two;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) { //The activity is being Created Create any threads/streams here
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mp1 = MediaPlayer.create(this, R.raw.bassfifteen);
mp2 = MediaPlayer.create(this, R.raw.snarenine);
button_one = (Button) findViewById(R.id.buttonOne);
button_one.setOnClickListener(this);
button_two = (Button) findViewById(R.id.buttonTwo);
button_two.setOnClickListener(this);
时 时
@Override
protected void onStart(){ //The activity is about to become visible
super.onStart();
//TODO set state for program start
时 时
@Override
protected void onResume(){ //The activity has become visible(it is now "resumed")
super.onResume();
//TODO set state for program resume
时 时
@Override
protected void onPause(){ // Another activity is taking focus (this activity will be "paused")
super.onPause();
//TODO set state for program hang
时 时
@Override
protected void onStop(){ // This activity is no longer visibled (it is "stopped")
super.onStop();
//TODO set state for program drop back
时 时
@Override
protected void onDestroy(){ // The Activity is about too be destoryed (exiting) Destroy all threads and streams here
super.onDestroy();
//TODO set state for program exit
时 时
@Override
public void onClick(View v) {
//Where the audio is fired
if(v == button_one){ mp1.start();时 时
if(v == button_two){ mp2.start();时 时
时 时
时 时