Skip to content

Commit cd4d405

Browse files
committed
audiobook: null-check MediaPlayer
1 parent b95ba91 commit cd4d405

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/org/coolreader/tts/TTSControlService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,12 @@ public void work() {
13081308
SentenceInfo nextSentenceInfo = sentenceInfo.nextSentence;
13091309
if(sentenceInfo.audioFile == TTSControlService.this.audioFile){
13101310
if(nextSentenceInfo.isFirstSentenceInAudioFile){
1311-
if(mState == State.PLAYING && !mMediaPlayer.isPlaying()){
1311+
if(mState == State.PLAYING && (mMediaPlayer == null || !mMediaPlayer.isPlaying())){
13121312
//this is the last sentence in the file, and the media player ended
13131313
isAfterSentence = true;
13141314
}
13151315
}else{
1316-
if(mMediaPlayer.isPlaying()){
1316+
if(mMediaPlayer != null && mMediaPlayer.isPlaying()){
13171317
double curPos = mMediaPlayer.getCurrentPosition() / 1000.0;
13181318
if(curPos >= nextSentenceInfo.startTime){
13191319
isAfterSentence = true;

0 commit comments

Comments
 (0)