在使用MediaPlayer播放音频时报出 E/MediaPlayerNative: start called in state 1, mPlayer(0x0) @Overridepublic void onClick(View v){Bundle b = new Bundle ();switch(v.getId ()){case R.id.start: //获取一个Message变量,用来传递点
在使用MediaPlayer播放音频时报出 E/MediaPlayerNative: start called in state 1, mPlayer(0x0)
@Override public void onClick(View v){ Bundle b = new Bundle (); switch(v.getId ()){ case R.id.start: //获取一个Message变量,用来传递点击状态的值 msg = myHandle.obtainMessage (); //把状态的值放在Bundle对象里面 b.putInt(“status”,1); msg.setData(b); msg.sendToTarget (); break; case R.id.pause: msg = myHandle.obtainMessage (); b.putInt("status",2); msg.setData(b); msg.sendToTarget (); break; case R.id.restart: msg = myHandle.obtainMessage (); b.putInt("status",3); msg.setData(b); msg.sendToTarget (); break; case R.id.stop: msg = myHandle.obtainMessage (); b.putInt("status",4); msg.setData(b); msg.sendToTarget (); break; } } class MyHandle extends Handler{ public MyHandle(){ } public MyHandle(Looper looper){ super(looper); } @Override public void handleMessage(Message msg){ Bundle b = msg.getData (); int status = b.getInt("status"); if(status == 1){ mMediaPlayer.start (); }else if (status ==2){ mMediaPlayer.pause(); }else if(status == 3){ mMediaPlayer.seekTo(0); }else if(status == 4){ mMediaPlayer.stop(); mMediaPlayer.release (); mMediaPlayer = null; VideoActivity.this.finish (); }
总结
到此这篇关于Android Studio 视频播放失败 start called in state1 异常怎么解决的文章就介绍到这了,更多相关android studio 视频播放失败内容请搜索自由互联以前的文章或继续浏览下面的相关文章希望大家以后多多支持自由互联!