MediaPlayer.getCurrentPosition IllegalStateException错误

mac2022-06-30  21

除了判断player是否等于null,还要判断isplaying,否者报错public void run() { // TODO Auto-generated method stub boolean isTrue=true; while(isTrue=true){ try{ Thread.sleep(1000); }catch(InterruptedException e){ e.printStackTrace(); } if(player==null){ isTrue=false; }else{ if(player.isPlaying()){//这是插入的代码 int position=player.getCurrentPosition(); Message msg=handler.obtainMessage(); msg.what=position; handler.sendEmptyMessage(position); } } }

 

转载于:https://www.cnblogs.com/wdc224/p/3801480.html

最新回复(0)