Android Studio添加了声音错误

时间:2015-09-15 17:42:50

标签: android audio

我正在尝试添加声音,但有错误:Cannot resolve method 'create(com.game.tobias.game.Explosion, int'为什么是int?

代码:

MediaPlayer explosion;
explosion = MediaPlayer.create(this, R.raw.mpExplosion)
explosion.start();

1 个答案:

答案 0 :(得分:0)

尝试使用getApplicationContext()获取上下文:

MediaPlayer explosion;
explosion = MediaPlayer.create(getApplicationContext(), R.raw.mpExplosion)
explosion.start();