Repository navigation
Fix juz' look-ahead using stale page bounds in getLastAyahToPlay - #4026
Open
m86hussein wants to merge 1 commit into
Open
m86hussein wants to merge 1 commit into
m86hussein wants to merge 1 commit into
Conversation
getLastAyahToPlay read pageLastSura/pageLastAyah in its juz' branch, but a 2020 refactor (quran#1386) moved the computation of those values into the page-mode branch only. In juz' mode they stayed at their 114/6 defaults, so 'pageLastSura > endJuz.sura' was always true and playback always jumped to the next juz' (getQuarterForNextJuz) instead of stopping at the current juz' boundary. Compute the page's last sura/ayah before the mode branches, restoring the original behavior. Added juz' look-ahead tests to AudioUtilsTest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix juz' look-ahead in
AudioUtils.getLastAyahToPlayreading stale page bounds.Why
getLastAyahToPlayusespageLastSura/pageLastAyahin its juz' (LookAheadAmount.JUZ) branch to decide whether the current page already spills into the next juz':A 2020 refactor (#1386) moved the computation of
pageLastSura/pageLastAyahinto the page-mode (else) branch only. In juz' mode they therefore kept their initial114/6defaults, sopageLastSura > endJuz.sura(114 > endJuz.sura) was always true. As a result, selecting "play by juz'" always ran past the current juz' into the following one (getQuarterForNextJuz) instead of stopping at the juz' boundary.Example: starting on page 5 (juz' 1), playback should stop at the start of juz' 2 (
2:142), but it stopped at the start of juz' 3 (2:253).Change
Compute the page's last sura/ayah (via
getVerseRangeForPage, exactly as the page-mode branch already did) before the mode branches, so the juz' branch sees the real page bounds. Page and sura modes are unaffected.Tests
Added juz' look-ahead tests to
AudioUtilsTest:2:1423:93114:6The first two fail against the previous code and pass with the fix. Full
AudioUtilsTestsuite (9 tests) passes.