Skip to content
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

EKIRJASTO-242 fix current audiobook player #192

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

natlibfi-burger
Copy link
Contributor

What's this do?
This pr attempts to fix the sleep timer and empty space at the end of the audiobook chapters when on greater player speeds. Also attempts to fix bookmarks going to incorrect spots when in faster speeds.
The buttons also get translated texts, that were previously only in English.

When it comes to the sleep timer, when set to end of chapter, the timer wouldn't work. This was because the audiobook would jump to the next chapter at the same time as the pause request came, so the pause got overwritten. This is now fixed by a boolean check, so if the sleep timer is on and we start a new chapter, we pause at the beginning of it.
Also fixed timer start for the cases we want to not start the sleep timer. It used to always start the end chapter timer that did not work, but now it can also not start a player.

For the empty space at the end of chapter, the problem was that the player doesn't recognize the player speed is faster, and thus the normal length of the chapter is too long. This is now patched up by some computations that tries to keep in time with the shortened file, and keeps the visible seekbar at correct time, and using the seek bar to know when we should manually skip to the next chapter. Same technique that is used to keep the time, is used to have the bookmarks be at correct spots.

NOTE: This doesn't fix the audio book skipping to the next chapter too early when playing in 0.75x speed, as this is still done by the player itself.

Why are we doing this? (w/ JIRA link if applicable)
This is done as a temporary solution to the most annoying audioplayer bugs that present themselves to most users. Most of these will have to be reversed when we update the audioplayer module, at some point. But until then, this is done to better the user experience.

[EKIRJASTO-242] https://jira.it.helsinki.fi/browse/EKIRJASTO-242

How should this be tested? / Do these changes have associated tests?
When testing, check all buttons and their actions.
Changing speed should make the numbers running on the player run faster.
The seekbar should present accurately where we are in the audio book, and manually jumping to a particular spot should be accurate.
On higher speeds, putting a bookmark to a spot, after letting the player run for a little while, is accurate, and the jump goes to accurate spot.
"End of file" sleep timer should pause at the beginning of next chapter on all speeds.
There should be no empty space at the end of chapters.
Check that when jumping to next chapter, the player doesn't accidentally jump over a chapter (was problem at some point in the code).
At the end of a book, the player should pause.

NOTE: Opening books might require you to change readium:liblcp version from 2.1.0 -> 4.1.0 in build.gradle.kts (simplified-app-ekirjasto), as these changes are done in an older branch. Also check that in build_libraries.toml kotlin-toolkit versions are 2.4.1

Does this require updates to old Transifex strings? Have the translators been informed?
Does need some changes to old Strings

  • Informed translators

There was a problem with player having empty space at the end of the
player when playing the audiobook on faster speeds.
This might be thanks to deprecated code, but this pr provides some sort
of solution that is done locally, without needing changes to the
palace-audiobook library. Note that updating the player to some higher
version could fix this.

This solution does some computations to count the player soit that the
player should be on if the timing was working correctly.
The audiobook length is adjusted based on the playerspeed, but the
smaller times on the edges only move faster, not reflecting the actual
time.

The idea is that we manully compute when the player should skip to the
next chapter and then do it manually. The way this is done is by keeping
count of what is the last spot we jump to in the player, and as the
player doesn't recognize (or at least doensn't update us accordingly)
what moment the player is currently on, and it thinks it's still in
normal time, leabcing empty space in the end of the file, we consider
the time onwards from the last spot to be quickened up, and oupate our
seek bar accordingly. Then when our seek bar reaches its end, we should
be in a spot where the audiobook chapter is done, and we manually skip
to the next chapter.
The buttons were always in english, so add the correct titles to the
buttons that are translatable. Also fix the text for the sleep timer
to a shorter version.

Do these changes for both of the text files that are copies of one
anouther, just in case the files need to match.
Jumping to a bookmark from the same chapter, from a point that was
earlier than the bookmark caused the player to jump to next chapter.
Fixed this by adding a check to see if the player made jumps that we
were unaware of. Bookmarks were also placed incorrectly on sped up
books, so fixed that by first jumping to current spot so when we call
the player to make a bookmark from current spot, it is the spot the user
is hearing.

The end to chapter sleep timer did not work, so made a check to our new
end of chapter check to see if we have sleep timer with end of chapter
running, and pausing if we do. Also changed the initial value of sleep
timer, so instead of always starting with end of chapter timer running,
we have no timer running and make end of chapter timer if need be.

When the book ends, the book now pauses itself on all speeds. There is
code for a popup that asks if the user wants to return the book, but
that is never triggered. This could be fixed in later audiobook player
versions.
Attempt to fix the sleep timer by checking the sleep timer and setting a
boolean to true if chapter end needs to pause the player.
Keep the remaining time unchanged when changing the play speed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant