mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 11:49:33 +00:00
Fix playback position not saved after being changed, when episode is paused (#7911)
This commit is contained in:
parent
448e1c1b8b
commit
cfd9e1f886
@ -256,8 +256,8 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
|
||||
return item;
|
||||
}
|
||||
|
||||
public boolean isCurrentlyPlayingItem() {
|
||||
return item.getMedia() != null && PlaybackStatus.isCurrentlyPlaying(item.getMedia());
|
||||
public boolean isPlayingItem() {
|
||||
return item.getMedia() != null && PlaybackStatus.isPlaying(item.getMedia());
|
||||
}
|
||||
|
||||
public void notifyPlaybackPositionUpdated(PlaybackPositionEvent event) {
|
||||
|
||||
@ -347,7 +347,7 @@ public abstract class EpisodesListFragment extends Fragment
|
||||
public void onEventMainThread(PlaybackPositionEvent event) {
|
||||
for (int i = 0; i < listAdapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder) recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||
if (adapter != null) {
|
||||
for (int i = 0; i < adapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder) recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public class CompletedDownloadsFragment extends Fragment
|
||||
if (adapter != null) {
|
||||
for (int i = 0; i < adapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder) recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
for (int i = 0; i < adapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder)
|
||||
viewBinding.recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class DownloadsSection extends HomeSection {
|
||||
for (int i = 0; i < adapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder)
|
||||
viewBinding.recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
|
||||
for (int i = 0; i < recyclerAdapter.getItemCount(); i++) {
|
||||
EpisodeItemViewHolder holder = (EpisodeItemViewHolder)
|
||||
recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if (holder != null && holder.isCurrentlyPlayingItem()) {
|
||||
if (holder != null && holder.isPlayingItem()) {
|
||||
holder.notifyPlaybackPositionUpdated(event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import android.util.Pair;
|
||||
import android.view.SurfaceHolder;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import de.danoeh.antennapod.playback.service.internal.PlayableUtils;
|
||||
import de.danoeh.antennapod.storage.database.DBReader;
|
||||
import de.danoeh.antennapod.storage.database.DBWriter;
|
||||
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
|
||||
@ -376,13 +377,18 @@ public abstract class PlaybackController {
|
||||
}
|
||||
|
||||
public void seekTo(int time) {
|
||||
Playable playable = getMedia();
|
||||
if (playbackService != null) {
|
||||
if (playable != null) {
|
||||
long timestamp = playable.getLastPlayedTimeStatistics();
|
||||
PlayableUtils.saveCurrentPosition(playable, time, timestamp);
|
||||
}
|
||||
playbackService.seekTo(time);
|
||||
} else if (getMedia() instanceof FeedMedia) {
|
||||
FeedMedia media = (FeedMedia) getMedia();
|
||||
} else if (playable instanceof FeedMedia) {
|
||||
FeedMedia media = (FeedMedia) playable;
|
||||
media.setPosition(time);
|
||||
DBWriter.setFeedItem(media.getItem());
|
||||
EventBus.getDefault().post(new PlaybackPositionEvent(time, getMedia().getDuration()));
|
||||
EventBus.getDefault().post(new PlaybackPositionEvent(time, playable.getDuration()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user