小编给大家分享一下Android Studio 视频播放失败 start called in state1异常的解决方法,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
在使用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异常的解决方法”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。