Merge pull request #2568 from ByteHamster/crashfix

Fixed crash if media file exists but can not be read
This commit is contained in:
Martin Fietz 2018-04-01 23:21:27 +02:00 committed by GitHub
commit 9cd9d455c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import android.view.SurfaceHolder;
import org.antennapod.audio.MediaPlayer;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
@ -165,8 +166,10 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
callback.onMediaChanged(false);
if (stream) {
mediaPlayer.setDataSource(media.getStreamUrl());
} else {
} else if (new File(media.getLocalMediaUrl()).canRead()) {
mediaPlayer.setDataSource(media.getLocalMediaUrl());
} else {
throw new IOException("Unable to read local file " + media.getLocalMediaUrl());
}
setPlayerStatus(PlayerStatus.INITIALIZED, media);