android MediaPlayer start called in state 2

描述

void previewVideo() {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    if (segmentArray.size() > 0 && surfaceCreated) {
try {
if (mPlayer == null) {
mPlayer = new MediaPlayer();
}
currentPreviewIndex = 0;
mPlayer.setDataSource(segmentArray.get(0));
mPlayer.setSurface(dataBinding.previewSurfaceView.getHolder().getSurface());
mPlayer.setOnCompletionListener(mediaPlayerComplete);
mPlayer.start();
} catch (IOException e) {
releaseMediaPlayer();
}
}
}
1
2
3
09-30 16:40:22.217 1836-1836/com.caiyi.youle E/MediaPlayer: start called in state 2
09-30 16:40:22.217 1836-1836/com.caiyi.youle E/MediaPlayer: error (-38, 0)
09-30 16:40:22.349 1836-1836/com.caiyi.youle E/MediaPlayer: Error (-38,0)

原因:没有调用 prepare