0

when I try to run soundpool in my program, it keeps giving me an error.

firstly, I added

SoundPool sp;

int shot = 0;

at the beginning of the program. Then I tried to add sound in the method that I wanted it to run by adding the following code,

sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);

shot = sp.load(this, R.raw.sound, 1); 

However, it keeps underlining .load and kept saying "The method load(Context, int, int) in the type SoundPool is not applicable for the arguments (GameView, int, int)"

How can I fix this?

1 Answer 1

0

You can't pass a view as the first parameter, it needs to be a context. Use this.getContext() instead.

1
  • I added context instead of 'this' and it worked. Thank you very much.
    – coder
    Apr 29, 2015 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.