updateSeekBar = new Thread() {
@Override
public void run() {
int runtime = mediaPlayer.getDuration();
int currentPosition = 0;
while (currentPosition < runtime) {
try {
sleep(500);
currentPosition = mediaPlayer.getCurrentPosition();//This is where the app crash
if (seekBar != null) {
seekBar.setProgress(currentPosition);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
故障报告
06-10 22:08:53.160 15351-15560/skydeveloper.me.musicx2 E/AndroidRuntime: FATAL EXCEPTION: Thread-6875
Process: skydeveloper.me.musicx2, PID: 15351
java.lang.IllegalStateException
at android.media.MediaPlayer.getCurrentPosition(Native Method)
at skydeveloper.me.musicx2.Player$1.run(Player.java:104)