The create(...)
method of MediaPlayer
requires a Context
as the first parameter. The problem is likely to be your Game class is a View
(which doesn't extend Context
) so using this
for the first parameter won't work.
You could try holding a reference to the Context
which is passed into the constructor. Under the private field private Paint caneta;
add one for the Context
. Example...
public class Game extends View {
private Cell[][] singlesquare = null;
int x = 3;
int y = 3;
private int l;
private int a;
private boolean whatdrawn = false;
private int playerwin = 3;
private Paint caneta;
private Context context; // ADD THIS LINE
Then in the constructor save a reference to the Context
passed in. Example...
public Game(Context context) {
super(context);
this.context = context; // ADD THIS LINE
Then when you create the Mediaplayer
use...
final MediaPlayer mp = MediaPlayer.create(context, R.raw.move);