aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-12-26 22:22:47 -0800
committerScott Jackson <daneren2005@gmail.com>2012-12-26 22:22:47 -0800
commit48baac66013161e4d0688ac0714cba8f43a81c7d (patch)
tree9b017ba4081f08aa8f94646c5f6e510a7992816d /subsonic-android
parentf634b360df15b8e30d459772fdc774937dd355d9 (diff)
downloaddsub-48baac66013161e4d0688ac0714cba8f43a81c7d.tar.gz
dsub-48baac66013161e4d0688ac0714cba8f43a81c7d.tar.bz2
dsub-48baac66013161e4d0688ac0714cba8f43a81c7d.zip
Fix for skipping issue
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 0c4d7930..2a84248d 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -95,6 +95,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private final Scrobbler scrobbler = new Scrobbler();
private final JukeboxService jukeboxService = new JukeboxService(this);
private DownloadFile currentPlaying;
+ private File currentPlayingFile;
private DownloadFile currentDownloading;
private CancellableTask bufferTask;
private PlayerState playerState = IDLE;
@@ -823,6 +824,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
// TODO: Start play at curr pos on rebuffer instead of restart
try {
final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile();
+ currentPlayingFile = file;
downloadFile.updateModificationDate();
mediaPlayer.setOnCompletionListener(null);
mediaPlayer.reset();
@@ -832,7 +834,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
setPlayerState(PREPARING);
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
- public void onPrepared(MediaPlayer mp) {
+ public void onPrepared(MediaPlayer mediaPlayer) {
try {
setPlayerState(PREPARED);
@@ -900,6 +902,17 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
});
+ mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
+ public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
+ Log.w(TAG, "Error on playing file " + "(" + what + ", " + extra + "): " + currentPlayingFile.getPath());
+ reset();
+ downloadFile.setPlaying(false);
+ doPlay(downloadFile, 0, true);
+ downloadFile.setPlaying(true);
+ return true;
+ }
+ });
+
mediaPlayer.prepareAsync();
} catch (Exception x) {
handleError(x);
@@ -954,6 +967,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
private void handleError(Exception x) {
+ Log.w(TAG, "Media player error with file: " + currentPlayingFile.getPath());
Log.w(TAG, "Media player error: " + x, x);
mediaPlayer.reset();
setPlayerState(IDLE);