diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index 70ea98af3..77d450f70 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -299,11 +299,11 @@ public class AudioPlayerFragment extends Fragment implements } private void updateUi(Playable media) { - if (controller == null) { + if (controller == null || media == null) { return; } duration = controller.getDuration(); - updatePosition(new PlaybackPositionEvent(controller.getPosition(), duration)); + updatePosition(new PlaybackPositionEvent(media.getPosition(), media.getDuration())); updatePlaybackSpeedButton(new SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media))); setChapterDividers(media); setupOptionsMenu(media); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 9f7a943fc..d1ab44572 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -99,12 +99,6 @@ public class ExternalPlayerFragment extends Fragment { private PlaybackController setupPlaybackController() { return new PlaybackController(getActivity()) { - - @Override - public void onPositionObserverUpdate() { - ExternalPlayerFragment.this.onPositionObserverUpdate(); - } - @Override protected void updatePlayButtonShowsPlay(boolean showPlay) { butPlay.setIsShowPlay(showPlay); @@ -142,8 +136,15 @@ public class ExternalPlayerFragment extends Fragment { } @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(PlaybackPositionEvent event) { - onPositionObserverUpdate(); + public void onPositionObserverUpdate(PlaybackPositionEvent event) { + if (controller == null) { + return; + } else if (controller.getPosition() == PlaybackService.INVALID_TIME + || controller.getDuration() == PlaybackService.INVALID_TIME) { + return; + } + progressBar.setProgress((int) + ((double) controller.getPosition() / controller.getDuration() * 100)); } @Subscribe(threadMode = ThreadMode.MAIN) @@ -195,7 +196,7 @@ public class ExternalPlayerFragment extends Fragment { ((MainActivity) getActivity()).setPlayerVisible(true); txtvTitle.setText(media.getEpisodeTitle()); feedName.setText(media.getFeedTitle()); - onPositionObserverUpdate(); + onPositionObserverUpdate(new PlaybackPositionEvent(media.getPosition(), media.getDuration())); RequestOptions options = new RequestOptions() .placeholder(R.color.light_gray) @@ -220,15 +221,4 @@ public class ExternalPlayerFragment extends Fragment { ((MainActivity) getActivity()).getBottomSheet().setLocked(false); } } - - private void onPositionObserverUpdate() { - if (controller == null) { - return; - } else if (controller.getPosition() == PlaybackService.INVALID_TIME - || controller.getDuration() == PlaybackService.INVALID_TIME) { - return; - } - progressBar.setProgress((int) - ((double) controller.getPosition() / controller.getDuration() * 100)); - } }