Android Mediaplayer报错

顺序播放五六首歌曲的时候机会出现错误
(-38,0);
Attempt to call getDuation withot a valid mediaplayer
下面代码
class OnCompletionListener implements android.media.MediaPlayer.OnCompletionListener {

    @Override
    public void onCompletion(MediaPlayer mp) {
        if (currIndex >= (list.size() - 1)) {
            statethreadFlag = true;
            mp.stop();
            Toast.makeText(getApplicationContext(), "歌曲全部播放完毕", Toast.LENGTH_LONG).show();
        } else {
            statethreadFlag = true;
            mp.stop();
            currIndex++;
            start();
        }
    }
}
public void start() {
    Log.i("mp3", "服务执行了start方法,开始播放歌曲");
    if (bundle.getBoolean("flag")) {
        hMap = list.get(currIndex);
        player.reset();
        try {
            player.setDataSource(hMap.get("path"));
            player.prepare();
        } catch (Exception e) {
            e.printStackTrace();
        }
        player.setOnPreparedListener(new OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mp.start();
                serviceFlag = 1;
                statethreadFlag = false;
                new Thread(new StateThread()) {
                }.start();
            }
        });
        class StateThread implements Runnable {
    @Override
    public void run() {
        Log.i("mp3", "服务线程启动");
        while (!statethreadFlag) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }               
            nowTime = player.getCurrentPosition();
            allTime = player.getDuration();
            Log.i("mp3", nowTime + " " + allTime + "");
            Intent stateIntent = new Intent();
            Bundle bundle = new Bundle();
            stateIntent.setAction("com.player.broadcast");
            bundle.putInt("now", nowTime);
            bundle.putInt("all", allTime);
            bundle.putInt("serviceFlag", serviceFlag);
            bundle.putInt("currIndex", currIndex);
            stateIntent.putExtra("state", bundle);
            sendBroadcast(stateIntent);

            if (nowTime >= allTime) {
                break;
            }

        }
    }
}
网上找了一天也没解决这个问题
出错了取得的nowTime和allTime 都是-1261004135
希望大神指教,感激不尽,只剩1c币了

应该是下标问题,链表的长度没弄好,取总时间的时候没有对应的mediaPlayer播放歌曲 估计是