You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a new audiobook navigator based on Jetpack Media2 (#80)
This new audiobook navigator departs from the previous one in the following way:
- No `MediaController` is used.
- No `Service` provided and no UI-related stuff (including for the notification zone).
- Apps must build a `MediaControllerSession`, use a helper to get a session from it, and connect that session to their media service.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
All notable changes to this project will be documented in this file. Take a look at [the migration guide](docs/migration-guide.md) to upgrade between two major versions.
4
4
5
-
**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.
5
+
**Warning:** Features marked as *experimental* may change or be removed in a future release without notice. Use with caution.
6
6
7
7
## [Unreleased]
8
8
@@ -32,6 +32,10 @@ All notable changes to this project will be documented in this file. Take a look
32
32
*The new `Navigator.Listener.onJumpToLocator()` APIis called every time the navigator jumps to an explicit location, which might break the linear reading progression.
33
33
*For example, it is called when clicking on internal links or programmatically calling `Navigator.go()`, but notwhen turning pages.
34
34
*You can use this callback to implement a navigation history by differentiating between continuous and discontinuous moves.
35
+
* (*experimental*) A new audiobook navigator based on Jetpack `media2`.
36
+
*See the [pull request #80](https://github.com/readium/kotlin-toolkit/pull/80) for the differences with the previous audiobook navigator.
37
+
*This navigator is located in its own module `readium-navigator-media2`. You will need to add it to your dependencies to use it.
38
+
*TheTestApp demonstrates how to use the new audiobook navigator, see `MediaService` and `AudioReaderFragment`.
35
39
36
40
### Deprecated
37
41
@@ -86,7 +90,7 @@ All notable changes to this project will be documented in this file. Take a look
86
90
87
91
#### Shared
88
92
89
-
* (*alpha*) A new Publication `SearchService` to search through the resources' content, with a default implementation `StringSearchService`.
93
+
* (*experimental*) A new Publication `SearchService` to search through the resources' content, with a default implementation `StringSearchService`.
90
94
* `ContentProtection.Scheme` can be used to identify protection technologies using unique URI identifiers.
91
95
* `Link` objects from archive-based publication assets (e.g. an EPUB/ZIP) have additional properties for entry metadata.
92
96
```json
@@ -108,12 +112,12 @@ All notable changes to this project will be documented in this file. Take a look
108
112
109
113
* The EPUB navigator is now able to navigate to a `Locator` using its `text` context. This is useful for search results or highlights missing precise locations.
110
114
* Get or clear the current user selection of the navigators implementing `SelectableNavigator`.
111
-
* (*alpha*) Support for the [Decorator API](https://github.com/readium/architecture/pull/160) to draw user interface elements over a publication's content.
115
+
* (*experimental*) Support for the [Decorator API](https://github.com/readium/architecture/pull/160) to draw user interface elements over a publication's content.
112
116
*This can be used to render highlights over a text selection, for example.
113
117
*For now, only the EPUB navigator implements `DecorableNavigator`, for reflowable publications. You can implement custom decoration styles with `HtmlDecorationTemplate`.
114
118
*Customize the EPUB selection context menu by providing a custom `ActionMode.Callback` implementation with `EpubNavigatorFragment.Configuration.selectionActionModeCallback`.
115
119
*Thisis an alternative to overriding `Activity.onActionModeStarted()` which does not seem to work anymore with Android12.
116
-
* (*alpha*) A new audiobook navigator based on Android's [`MediaSession`](https://developer.android.com/guide/topics/media-apps/working-with-a-media-session).
120
+
* (*experimental*) A new audiobook navigator based on Android's [`MediaSession`](https://developer.android.com/guide/topics/media-apps/working-with-a-media-session).
117
121
* It supports out-of-the-box media style notifications and background playback.
118
122
* ExoPlayer is used by default for the actual playback, but you can use a custom player by implementing `MediaPlayer`.
119
123
@@ -327,7 +331,7 @@ progression. Now if no reading progression is set, the `effectiveReadingProgress
327
331
#### Navigator
328
332
329
333
*Supportfor the new `Publication` model using the [ContentProtection](https://readium.org/architecture/proposals/006-content-protection) for DRM rights and the [Fetcher](https://readium.org/architecture/proposals/002-composite-fetcher-api) for resource access.
330
-
* (*alpha*) New `Fragment` implementations as an alternative to the legacy `Activity` ones (contributed by [@johanpoirier](https://github.com/readium/r2-navigator-kotlin/pull/148)).
334
+
* (*experimental*) New `Fragment` implementations as an alternative to the legacy `Activity` ones (contributed by [@johanpoirier](https://github.com/readium/r2-navigator-kotlin/pull/148)).
331
335
*The fragments are chromeless, to let you customize the reading UX.
332
336
*To create the fragments use the matching factory such as `EpubNavigatorFragment.createFactory()`, as showcased in `R2EpubActivity`.
333
337
*At the moment, highlights andTTS are not yet supported in the new EPUB navigator `Fragment`.
@@ -424,13 +428,13 @@ progression. Now if no reading progression is set, the `effectiveReadingProgress
424
428
* Get the visible position from the current `Locator` with `locations.position`.
425
429
* The total number of positions can be retrieved with `publication.positions().size`. It is a suspending function because computing positions the first time can be expensive.
426
430
* `ReadiumWebPubParser` to parse all Readium Web Publication profiles, including [Audiobooks](https://readium.org/webpub-manifest/extensions/audiobook.html), [LCP for Audiobooks](https://readium.org/lcp-specs/notes/lcp-for-audiobooks.html) and [LCP for PDF](https://readium.org/lcp-specs/notes/lcp-for-pdf.html). It parses both manifests and packages.
427
-
* (*alpha*) `PDFParser` to parse single PDF documents.
431
+
* (*experimental*) `PDFParser` to parse single PDF documents.
428
432
* The PDF parser is based on [PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid/), which may increase the size of your apps. Please open an issue if this is a problem for you, as we are considering different solutions to fix this in a future release.
429
433
430
434
#### Navigator
431
435
432
436
* The [position](https://github.com/readium/architecture/tree/master/models/locators/positions) is now reported in the locators for EPUB, CBZ and PDF.
* As a proof of concept, [it is implemented using `Fragment` instead of `Activity`](https://github.com/readium/r2-navigator-kotlin/issues/115). `R2PdfActivity` showcases how to use the `PdfNavigatorFragment` with the new `NavigatorFragmentFactory`.
436
440
* The navigator is based on [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer), which may increase the size of your apps. Please open an issue if this is a problem for you, as we are considering different solutions to fix this in a future release.
classReadFailed(uri:Uri, offset:Int, readLength:Int, cause:Throwable) : ExoPlayerDataSourceException("Failed to read $readLength bytes of URI $uri at offset $offset.", cause)
26
+
}
27
+
28
+
/**
29
+
* An ExoPlayer's [DataSource] which retrieves resources from a [Publication].
val link = publication.linkWithHref(dataSpec.uri.toString())
54
+
?:throwExoPlayerDataSourceException.NotFound("Can't find a [Link] for URI: ${dataSpec.uri}. Make sure you only request resources declared in the manifest.")
55
+
56
+
val resource = publication.get(link)
57
+
// Significantly improves performances, in particular with deflated ZIP entries.
0 commit comments