I have used the mediaplayer before, and I have never had this problem. Whenever I try to use MediaPlayer.create(), the method gives me null, and I can't play my sounds. Is there anything that I am missing?
public class Game extends Activity
{
private MediaPlayer mp = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
mp = MediaPlayer.create(getBaseContext(), R.raw.sound);
}
}
my sound.mp3 is in my raw folder, which I placed in there by draging my sound to the folder in eclipse. Please help, since I have played sound before, this is really bugging me :(
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…