Mediaplayer.start()返回一个空值

package com.example.zhengli.mediaplayerdemo;

import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private Button mb1;

private MediaPlayer mpplayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mb1=(Button)findViewById(R.id.play);
mb1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mpplayer=new MediaPlayer();
mpplayer=MediaPlayer.create(MainActivity.this,R.raw.mp);
mpplayer.start();
}
});

}

@Override
protected void onDestroy() {
super.onDestroy();
if(mpplayer.isPlaying()){
mpplayer.stop();
}
mpplayer.release();//释放资源
}
}
2018-04-14 15:45 添加评论 分享
已邀请:

要回复问题请先登录注册

退出全屏模式 全屏模式 回复