Skip to content

Commit 6ea996f

Browse files
authored
Fix TTS in a fixed-layout EPUB (#555)
1 parent 7c08d29 commit 6ea996f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. Take a look
1111
#### Navigator
1212

1313
* Fixed computing the total progression of audiobook locators.
14+
* Fixed starting the TTS from the current resource in a fixed-layout EPUB.
1415

1516

1617
## [3.0.0-beta.2]

readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,12 +1008,19 @@ public class EpubNavigatorFragment internal constructor(
10081008
override suspend fun firstVisibleElementLocator(): Locator? {
10091009
if (!::resourcePager.isInitialized) return null
10101010

1011-
val resource = readingOrder[resourcePager.currentItem]
1012-
return currentReflowablePageFragment?.webView?.findFirstVisibleLocator()
1013-
?.copy(
1014-
href = resource.url(),
1015-
mediaType = resource.mediaType ?: MediaType.XHTML
1016-
)
1011+
return when (viewModel.layout) {
1012+
EpubLayout.FIXED ->
1013+
currentLocator.value
1014+
1015+
EpubLayout.REFLOWABLE -> {
1016+
val resource = readingOrder[resourcePager.currentItem]
1017+
currentReflowablePageFragment?.webView?.findFirstVisibleLocator()
1018+
?.copy(
1019+
href = resource.url(),
1020+
mediaType = resource.mediaType ?: MediaType.XHTML
1021+
)
1022+
}
1023+
}
10171024
}
10181025

10191026
/**

0 commit comments

Comments
 (0)