New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fast-forward at end of episode #6074
Conversation
@terminalmage any chance this also addresses #5166? |
@loucasal It seems like it might, though I have never encountered the exact issue you reported. But both bugs seem to be triggered under similar circumstances. |
This will have unwanted side effects.
|
I had a feeling my first crack at fixing this would not be the best 😆 What do you suggest? |
I don't really know |
Perhaps this can be targeted more narrowly. For example, in the bug that I reported, the code as-is will attempt to skip forward but just.... won't do that. Is there a good way to detect when the skip-forward is unsuccessful, and simply skip the current episode in these cases? Maybe the position could be checked after the seek. If the position is not >= the desired seek position, then the seek was unsuccessful, and we can assume the end-of-episode has been reached. What do you think? EDIT: I tried this, and it looks like the seek happens asynchronously, so you can't reliably check the position immediately after calling |
@keunes @ByteHamster As discussed in the most recent community call, I did eventually get a chance to see how another open-source player (Pocket Casts) handles skip-forward at the end of the file. Here is the relevant function: https://github.com/Automattic/pocket-casts-android/blob/09c5634/modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PlaybackManager.kt#L710-L732 They seem to be taking the same approach that I did independently when I opened this PR. If the new position is >= to the episode length, the episode is considered completed. @ByteHamster had concerns with this approach, because the episode length in milliseconds is an estimate when the audio file is encoded with VBR. However, in my experience, skip forward always worked until I got to the last 10-15 seconds of an episode. Once you get near the end, skipping forward fails because we are telling exoplayer to skip to a position that doesn't actually exist. I believe that people using skip forward at the end of an episode are typically doing so aware of the fact that they're at the end of the episode, and the expected behavior when you press the skip-forward button with <30 seconds remaining is that the episode is finished. I have rebased and slightly altered this pull request, as it wasn't building with changes made to AudioPlayerFragment in the time since I initially opened the PR. |
Sorry for the late reply. Shouldn't the skipping decision be made in the media player instead of the UI? Eg if you fast-forward from the notification, the widget, the player screen, headphones, etc, it should behave the same, I think. |
This issue has been mentioned on AntennaPod Forum. There might be relevant details there: https://forum.antennapod.org/t/monthly-community-call/1869/53 |
That makes sense. I only found that one place where skip-forward was already being implemented (there could definitely be others I missed), and made my changes there. I'm not 100% sure where you're suggesting the code is moved, though. |
My idea (not having looked at the code) was to do it in LocalPSMP |
Hi @terminalmage, are you still interested in this PR? I would say let's give it a try if you move the code over to |
Yeah, I'm interested. I should have some time to work on this later in the week. I'll let you know if I have any questions. |
When using variable speed, skipping back and forth introduces some uncertainty to the current position, causing skip-forward to try to skip to an invalid position when very near the end of the episode. This change fixes this by skipping the current episode if the desired skip-forward position exceeds the duration. Fixes AntennaPod#5974.
cd7bb93
to
4c9fa3b
Compare
@ByteHamster I have the code moved into LocalPSMP, but it doesn't work quite right. If you look at the updated diff, There's a call there to
|
Shouldn't you return after calling |
@ByteHamster Yeah that worked, thanks. This should be ready for review and merge now. |
core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
Outdated
Show resolved
Hide resolved
Thanks. Will be released in 3.2.0. Let's hope that this does not cause problems when the media is VBR encoded. |
When using variable speed, skipping back and forth introduces some uncertainty to the current position, causing skip-forward to try to skip to an invalid position when very near the end of the episode. This change fixes this by skipping the current episode if the desired skip-forward position exceeds the duration.
Merging AntennaPod#6074 has caused a new edge case for VBR audio files, in which using the seek bar to seek to the end of an episode sometimes hits the new code path, and the `skip()` function is called. Because `skip()` invokes `endPlayback()` with `hasEnded` set to `false`, post-processing tasks are not executed unless the pre-seek position falls within the "Smart mark as played" range. If "Smart mark as played" is set to `Disabled`, or the pre-seek position is outside that range, then the episode is not marked as played, and not removed from queue. This commit fixes that edge case by replacing `skip()` with a direct call to `endPlayback()`, with `hasEnded` set to `true`.
Merging #6074 has caused a new edge case for VBR audio files, in which using the seek bar to seek to the end of an episode sometimes hits the new code path, and the `skip()` function is called. Because `skip()` invokes `endPlayback()` with `hasEnded` set to `false`, post-processing tasks are not executed unless the pre-seek position falls within the "Smart mark as played" range. If "Smart mark as played" is set to `Disabled`, or the pre-seek position is outside that range, then the episode is not marked as played, and not removed from queue. This commit fixes that edge case by replacing `skip()` with a direct call to `endPlayback()`, with `hasEnded` set to `true`.
When using variable speed, skipping back and forth introduces some uncertainty to the current position, causing skip-forward to try to skip to an invalid position when very near the end of the episode. This change fixes this by skipping the current episode if the desired skip-forward position exceeds the duration.
Fixes #5974.
Please let me know if there is a more elegant solution, but this seems to work.