我找到了自己的答案。我不知道这是否是一个好方法,但是:
if(videoFile != null)
{
Log.i("INITPLAYER", videoFile);
afd = getAssets().openFd(videoFile);
instructionVideoPlayer = new MediaPlayer();
instructionVideoPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
instructionVideoPlayer.setDisplay(holder);
instructionVideoPlayer.prepare();
instructionVideoPlayer.setOnCompletionListener(instructionVideoComplete);
instructionVideoPlayer.setOnPreparedListener(this);
}
else
Log.i("VideoPlayer", "noVideoFile");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
Log.i(this.toString(), "IOEXception");
e.printStackTrace();
//Here is the fix:
instructionVideoPlayer.release();
instructionVideoPlayer = null;
initPlayer();
// reinit after prepare failed. although this can bring in an infinte loop if video file does not exits
} catch (Exception e)
{
Log.i("InitPlayer", e.getClass().toString());
e.printStackTrace();
}