So I have created a basic soundboard but am now looking to update the sound board to version 2.0
I would like to have a soundboard where when somebody clicks on a button the soundboard plays a random sound in that particular category.
Here is my basic soundboard code........
Your help is very much appreciated.
package com.example.benandhollysoundboard;
import android.R.layout;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class myMenu extends Activity {
MediaPlayer ben, holly, gaston, plum, queenthistle, kingthistle, robot, wiseoldelf, lucy;
ImageButton Ben, Holly, Gaston, Plum, Queenthistle, Kingthistle, Robot, Wiseoldelf, Lucy;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.Layout.activity_main);
Ben = MediaPlayer.create(this, R.raw.ben);
Ben = (ImageButton) findViewById(R.id.Ben);
Ben.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ben.start();
}
});
holly = MediaPlayer.create(this, R.raw.holly);
Holly = (ImageButton) findViewById(R.id.Holly);
Holly.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holly.start();
}
});
gaston = MediaPlayer.create(this, R.raw.gaston);
Gaston = (ImageButton) findViewById(R.id.Gaston);
Gaston.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gaston.start();
}
});
plum = MediaPlayer.create(this, R.raw.plum);
Plum = (ImageButton) findViewById(R.id.Plum);
Plum.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plum.start();
}
});
robot = MediaPlayer.create(this, R.raw.robot);
Robot = (ImageButton) findViewById(R.id.Robot);
Robot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
robot.start();
}
});
wiseoldelf = MediaPlayer.create(this, R.raw.wiseoldelf);
Wiseoldelf = (ImageButton) findViewById(R.id.Wiseoldelf);
Wiseoldelf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wiseoldelf.start();
}
});
lucy = MediaPlayer.create(this, R.raw.lucy);
Lucy = (ImageButton) findViewById(R.id.Lucy);
Lucy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
lucy.start();
}
});
kingthistle = MediaPlayer.create(this, R.raw.kingthistle);
Kingthistle = (ImageButton) findViewById(R.id.Kingthistle);
Kingthistle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
kingthistle.start();
}
});
queenthistle = MediaPlayer.create(this, R.raw.queenthistle);
Queenthistle = (ImageButton) findViewById(R.id.Queenthistle);
Queenthistle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
queenthistle.start();
}
});
}
}
.
stackoverflow.comm
No comments:
Post a Comment