在android studio中创建MediaPlayer

时间:2016-10-09 12:53:38

标签: android android-mediaplayer

我正在尝试在android studio中创建MediaPlayer,但在编译时它给出了

"unfortunately project has stopped"

代码如下:

MediaPlayer M = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    M = MediaPlayer.create(MainActivity.this,R.raw.laugh);

}

public void play1(View view) {
        M.start();
}

0 个答案:

没有答案