您的位置:首页技术文章
文章详情页

Android Studio 视频播放失败 start called in state1 异常怎么解决

【字号: 日期:2022-09-26 11:48:42浏览:3作者:猪猪

在使用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变量,用来传递点击状态的值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 视频播放失败 start called in state1 异常怎么解决的文章就介绍到这了,更多相关android studio 视频播放失败内容请搜索好吧啦网以前的文章或继续浏览下面的相关文章希望大家以后多多支持好吧啦网!

标签: Android
相关文章: