Fixed crash if media file exists but can not be read

Happens when exporting db and importing it into debug version
because media files are located in an app-private folder
This commit is contained in:
ByteHamster 2018-03-22 22:12:40 +01:00
parent c79b003dff
commit 4213d8fc8b
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);