From d21d1f0a0aa33ce291b586aecfef302d6b480b61 Mon Sep 17 00:00:00 2001 From: Anna <3488203-pajamas@users.noreply.gitlab.com> Date: Sat, 9 Sep 2023 22:06:16 +0300 Subject: [PATCH] created seekpodcast event and fixed podcast seeking Signed-off-by: Anna Soinio --- .../de/luhmer/owncloudnewsreader/PodcastFragment.java | 5 ++--- .../events/podcast/SeekPodcast.java | 11 +++++++++++ .../services/PodcastPlaybackService.java | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/SeekPodcast.java diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java index eeaa4267f..2b731190c 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java @@ -55,6 +55,7 @@ import de.luhmer.owncloudnewsreader.events.podcast.StartDownloadPodcast; import de.luhmer.owncloudnewsreader.events.podcast.TogglePlayerStateEvent; import de.luhmer.owncloudnewsreader.events.podcast.WindPodcast; +import de.luhmer.owncloudnewsreader.events.podcast.SeekPodcast; import de.luhmer.owncloudnewsreader.model.PodcastFeedItem; import de.luhmer.owncloudnewsreader.model.PodcastItem; import de.luhmer.owncloudnewsreader.services.PodcastDownloadService; @@ -303,12 +304,10 @@ public void onStopTrackingTouch(final SeekBar seekBar) { long ms = Math.round((after / 100d) * maxPositionInMillis); Log.v(TAG, "onStopTrackingTouch - after (%): " + after + " - ms: " + ms); - eventBus.post(new WindPodcast(ms)); + eventBus.post(new SeekPodcast(ms)); blockSeekbarUpdate = false; } }; - // TODO SEEK DOES NOT WORK PROPERLY!!!! - private void showPlaybackSpeedPicker() { final NumberPicker numberPicker = new NumberPicker(getContext()); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/SeekPodcast.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/SeekPodcast.java new file mode 100644 index 000000000..2b540ed7d --- /dev/null +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/SeekPodcast.java @@ -0,0 +1,11 @@ +package de.luhmer.owncloudnewsreader.events.podcast; + +public class SeekPodcast { + + public double milliSeconds; + + public SeekPodcast(double milliSeconds) { + this.milliSeconds = milliSeconds; + } + +} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/PodcastPlaybackService.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/PodcastPlaybackService.java index e3d255094..0d7c711e7 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/PodcastPlaybackService.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/PodcastPlaybackService.java @@ -55,6 +55,7 @@ import de.luhmer.owncloudnewsreader.events.podcast.SpeedPodcast; import de.luhmer.owncloudnewsreader.events.podcast.TogglePlayerStateEvent; import de.luhmer.owncloudnewsreader.events.podcast.WindPodcast; +import de.luhmer.owncloudnewsreader.events.podcast.SeekPodcast; import de.luhmer.owncloudnewsreader.model.MediaItem; import de.luhmer.owncloudnewsreader.model.PodcastFeedItem; import de.luhmer.owncloudnewsreader.model.PodcastItem; @@ -447,6 +448,14 @@ public void onEvent(WindPodcast event) { } } + @Subscribe + public void onEvent(SeekPodcast event) { + if(mPlaybackService != null) { + int seekTo = (int) (event.milliSeconds); + mPlaybackService.seekTo(seekTo); + } + } + @Subscribe public void onEvent(RegisterVideoOutput videoOutput) { if(mPlaybackService != null && mPlaybackService instanceof MediaPlayerPlaybackService) {