I'm trying to make a soundboard app, but I'm running into a problem with handling the sound files. More specifically I do not know how to get it so when a button is pressed it plays a corresponding sound back.
I've tried using this way Play sound on button click android
I tried implementing a media player for each sound file and button but the app crashes on start up.
I have 10 buttons with 10 corresponding sound files that are located in the raw file in src/res/raw/
Any idea on how to make it work?
//this is a breaking bad soundboard app, so please excuse the language. Sorry if you      find it offensive
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }
    whatup = (Button)this.findViewById(R.id.button);
    haveatit = (Button)this.findViewById(R.id.button2);
    hello = (Button)this.findViewById(R.id.button3);
    whining = (Button)this.findViewById(R.id.button7);
    money = (Button)this.findViewById(R.id.button4);
    yeah= (Button)this.findViewById(R.id.button8);
    miserable = (Button)this.findViewById(R.id.button5);
    mother = (Button)this.findViewById(R.id.button9);
    gatorade = (Button)this.findViewById(R.id.button6);
    science = (Button)this.findViewById(R.id.button10);
    whatup.setOnClickListener(this);
    haveatit.setOnClickListener(this);
    hello.setOnClickListener(this);
    whining.setOnClickListener(this);
    money.setOnClickListener(this);
    yeah.setOnClickListener(this);
    miserable.setOnClickListener(this);
    mother.setOnClickListener(this);
    gatorade.setOnClickListener(this);
    science.setOnClickListener(this);
    WhatUp = MediaPlayer.create(MainActivity.this, R.raw.whatupb);
    HaveAtIt = MediaPlayer.create(MainActivity.this, R.raw.haveatit);
    Hello = MediaPlayer.create(MainActivity.this, R.raw.hello);
    Whining = MediaPlayer.create(MainActivity.this, R.raw.stopwhining);
    Money = MediaPlayer.create(MainActivity.this, R.raw.wheresmymoney);
    Yeah = MediaPlayer.create(MainActivity.this, R.raw.yeahb);
    Miserable = MediaPlayer.create(MainActivity.this, R.raw.miserableb);
    Mother = MediaPlayer.create(MainActivity.this, R.raw.motherofgod);
    Gatorade = MediaPlayer.create(MainActivity.this, R.raw.gatorade);
    Science = MediaPlayer.create(MainActivity.this, R.raw.yeahscience);
}
this is for handling when the button is pressed. Obviously there needs to be more, but I was just testing 1 button and it crashes when I try starting it.
  @Override
public void onClick(View view) {
    if(view==whatup)
    {
        WhatUp.start();
    }
}
Log Cat Errors: https://i.stack.imgur.com/Hz4Sz.jpg
 
     
    