mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 19:04:52 +01:00
Fixed playbackService crash when trying to seek in INITIALIZED state
This commit is contained in:
parent
8c11b8e782
commit
72646abb9a
@ -938,6 +938,12 @@ public class PlaybackService extends Service {
|
||||
}
|
||||
|
||||
public void seek(int i) {
|
||||
saveCurrentPosition();
|
||||
if (status == PlayerStatus.INITIALIZED) {
|
||||
media.setPosition(i);
|
||||
setStartWhenPrepared(true);
|
||||
prepare();
|
||||
} else {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Seeking position " + i);
|
||||
if (shouldStream) {
|
||||
@ -947,7 +953,7 @@ public class PlaybackService extends Service {
|
||||
setStatus(PlayerStatus.SEEKING);
|
||||
}
|
||||
player.seekTo(i);
|
||||
saveCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
public void seekToChapter(Chapter chapter) {
|
||||
|
@ -355,7 +355,8 @@ 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();
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user