diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-07-02 17:38:59 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-07-02 17:38:59 +0200 |
commit | f2fe9553de10bf8ee31caea2733f8a50a29b4799 (patch) | |
tree | 9a85359661999b0d38cb3f15f2bd21d39ea3496d /src/de | |
parent | 4882a5ff920d41ba5d7a32998cf89ab29b5fda2f (diff) | |
download | AntennaPod-f2fe9553de10bf8ee31caea2733f8a50a29b4799.zip |
Improved stability of playbackService when handling an Error
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/podfetcher/activity/MediaplayerActivity.java | 3 | ||||
-rw-r--r-- | src/de/podfetcher/service/PlaybackService.java | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/de/podfetcher/activity/MediaplayerActivity.java b/src/de/podfetcher/activity/MediaplayerActivity.java index 4b3b04278..1eb6c90a1 100644 --- a/src/de/podfetcher/activity/MediaplayerActivity.java +++ b/src/de/podfetcher/activity/MediaplayerActivity.java @@ -559,6 +559,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements public class MediaPositionObserver extends AsyncTask<MediaPlayer, Void, Void> { + private static final String TAG = "MediaPositionObserver"; private static final int WAITING_INTERVALL = 1000; private MediaPlayer player; @@ -579,6 +580,8 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements Log.d(TAG, "Thread was interrupted while waiting. Finishing now"); return null; + } catch (IllegalStateException e) { + Log.d(TAG, "player is in illegal state, exiting now"); } publishProgress(); } diff --git a/src/de/podfetcher/service/PlaybackService.java b/src/de/podfetcher/service/PlaybackService.java index 26c1d4d70..07a24a2b1 100644 --- a/src/de/podfetcher/service/PlaybackService.java +++ b/src/de/podfetcher/service/PlaybackService.java @@ -523,12 +523,16 @@ public class PlaybackService extends Service { while (!isCancelled() && player.isPlaying()) { try { Thread.sleep(WAITING_INTERVALL); + saveCurrentPosition(); } catch (InterruptedException e) { Log.d(TAG, "Thread was interrupted while waiting. Finishing now..."); return null; + } catch (IllegalStateException e) { + Log.d(TAG, "Player is in illegal state. Finishing now"); + return null; } - saveCurrentPosition(); + } return null; } |