summaryrefslogtreecommitdiff
path: root/src/de/danoeh
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-11-25 13:13:08 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2012-11-25 13:13:08 +0100
commit72646abb9a1aa4578e4546c1ba8a90a1c6aa4bba (patch)
treeb794c8ac3048d808622b050ada39ab95ab653f06 /src/de/danoeh
parent8c11b8e782b2f7b007b724930ed985c2bee3cdce (diff)
downloadAntennaPod-72646abb9a1aa4578e4546c1ba8a90a1c6aa4bba.zip
Fixed playbackService crash when trying to seek in INITIALIZED state
Diffstat (limited to 'src/de/danoeh')
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java22
-rw-r--r--src/de/danoeh/antennapod/util/PlaybackController.java10
2 files changed, 19 insertions, 13 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 831e93df3..94025f627 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -938,16 +938,22 @@ public class PlaybackService extends Service {
}
public void seek(int i) {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Seeking position " + i);
- if (shouldStream) {
- if (status != PlayerStatus.SEEKING) {
- statusBeforeSeek = status;
+ saveCurrentPosition();
+ if (status == PlayerStatus.INITIALIZED) {
+ media.setPosition(i);
+ setStartWhenPrepared(true);
+ prepare();
+ } else {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Seeking position " + i);
+ if (shouldStream) {
+ if (status != PlayerStatus.SEEKING) {
+ statusBeforeSeek = status;
+ }
+ setStatus(PlayerStatus.SEEKING);
}
- setStatus(PlayerStatus.SEEKING);
+ player.seekTo(i);
}
- player.seekTo(i);
- saveCurrentPosition();
}
public void seekToChapter(Chapter chapter) {
diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java
index 0afb0450c..7d732f042 100644
--- a/src/de/danoeh/antennapod/util/PlaybackController.java
+++ b/src/de/danoeh/antennapod/util/PlaybackController.java
@@ -355,11 +355,12 @@ public abstract class PlaybackController {
* should be used to update the GUI or start/cancel background threads.
*/
private void handleStatus() {
- TypedArray res = activity.obtainStyledAttributes(new int[] {R.attr.av_play, R.attr.av_pause});
+ TypedArray res = activity.obtainStyledAttributes(new int[] {
+ R.attr.av_play, R.attr.av_pause });
final int playResource = res.getResourceId(0, R.drawable.av_play);
final int pauseResource = res.getResourceId(1, R.drawable.av_pause);
res.recycle();
-
+
switch (status) {
case ERROR:
@@ -472,7 +473,7 @@ public abstract class PlaybackController {
boolean fromUser, TextView txtvPosition) {
if (fromUser && playbackService != null) {
float prog = progress / ((float) seekBar.getMax());
- int duration = playbackService.getPlayer().getDuration();
+ int duration = media.getDuration();
txtvPosition.setText(Converter
.getDurationStringLong((int) (prog * duration)));
return prog;
@@ -494,8 +495,7 @@ public abstract class PlaybackController {
*/
public void onSeekBarStopTrackingTouch(SeekBar seekBar, float prog) {
if (playbackService != null) {
- playbackService.seek((int) (prog * playbackService.getPlayer()
- .getDuration()));
+ playbackService.seek((int) (prog * media.getDuration()));
setupPositionObserver();
}
}