Shawna N Leigh Good Posted June 25, 2012 Share Posted June 25, 2012 Hello, I am new to android development and need some help creating a sound testboard, to my knowledge my code should be perfect and work but when I run it in the emulator or on my tablet the sound doesnt work. If anyone can help would really appreciate it. Below is my code: package your.test.namespace; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; public class TestsoundboardActivity extends Activity implements OnClickListener{ Button bPlay; Button bPause; MediaPlayer mpAudio @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LinearLayout layout = new LinearLayout(this); Button bPlay = new Button(this); bPlay.setText("Play"); bPlay.setOnClickListener(this); Button bPause = new Button(this); bPause.setText("Pause"); bPause.setOnClickListener(this); layout.addView(bPlay); layout.addView(bPause); setContentView(layout); mpAudio = MediaPlayer.create(this,R.raw.killer); mpAudio.setLooping(true); } public void onClick(View v) { if (v==bPlay){ mpAudio.start(); }else if(v==bPause) { mpAudio.pause(); } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.