mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-01 11:16:47 +01:00
Fix sometimes showing incorrect position when continuous playback is disabled
This commit is contained in:
parent
bae923d710
commit
a291be9afb
@ -299,11 +299,11 @@ public class AudioPlayerFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUi(Playable media) {
|
private void updateUi(Playable media) {
|
||||||
if (controller == null) {
|
if (controller == null || media == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
duration = controller.getDuration();
|
duration = controller.getDuration();
|
||||||
updatePosition(new PlaybackPositionEvent(controller.getPosition(), duration));
|
updatePosition(new PlaybackPositionEvent(media.getPosition(), media.getDuration()));
|
||||||
updatePlaybackSpeedButton(new SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media)));
|
updatePlaybackSpeedButton(new SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media)));
|
||||||
setChapterDividers(media);
|
setChapterDividers(media);
|
||||||
setupOptionsMenu(media);
|
setupOptionsMenu(media);
|
||||||
|
@ -99,12 +99,6 @@ public class ExternalPlayerFragment extends Fragment {
|
|||||||
|
|
||||||
private PlaybackController setupPlaybackController() {
|
private PlaybackController setupPlaybackController() {
|
||||||
return new PlaybackController(getActivity()) {
|
return new PlaybackController(getActivity()) {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPositionObserverUpdate() {
|
|
||||||
ExternalPlayerFragment.this.onPositionObserverUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||||
butPlay.setIsShowPlay(showPlay);
|
butPlay.setIsShowPlay(showPlay);
|
||||||
@ -142,8 +136,15 @@ public class ExternalPlayerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(PlaybackPositionEvent event) {
|
public void onPositionObserverUpdate(PlaybackPositionEvent event) {
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@ -195,7 +196,7 @@ public class ExternalPlayerFragment extends Fragment {
|
|||||||
((MainActivity) getActivity()).setPlayerVisible(true);
|
((MainActivity) getActivity()).setPlayerVisible(true);
|
||||||
txtvTitle.setText(media.getEpisodeTitle());
|
txtvTitle.setText(media.getEpisodeTitle());
|
||||||
feedName.setText(media.getFeedTitle());
|
feedName.setText(media.getFeedTitle());
|
||||||
onPositionObserverUpdate();
|
onPositionObserverUpdate(new PlaybackPositionEvent(media.getPosition(), media.getDuration()));
|
||||||
|
|
||||||
RequestOptions options = new RequestOptions()
|
RequestOptions options = new RequestOptions()
|
||||||
.placeholder(R.color.light_gray)
|
.placeholder(R.color.light_gray)
|
||||||
@ -220,15 +221,4 @@ public class ExternalPlayerFragment extends Fragment {
|
|||||||
((MainActivity) getActivity()).getBottomSheet().setLocked(false);
|
((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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user