ReadingSystemEngine

ReadingSystemEngine is the entry point to the Colibrio Reading System API. It is used for loading publications, accessing the ReaderView, creating SyncMediaPlayers and more.

You get an engine instance from ColibrioReadingSystemView.readingSystemEngine.

Threading

Use the whole reading system API from the main thread - this engine, its ReaderView, the publications it loads and their timelines and SyncMediaPlayers. This includes the suspend overloads: call them from a coroutine on the main dispatcher rather than switching dispatchers first. The reading system drives an Android WebView, whose state is confined to the main thread.

Calls from another thread are not supported. The framework logs an error when it detects one, but the call may still lose its result or leave the reading system inconsistent.

That rule covers calls you make into the reading system. The reading system also calls into code you implement. Those calls arrive on the main thread, except for the resource interfaces: com.colibrio.core.io.ResourceProvider, com.colibrio.core.io.RandomAccessDataSource and com.colibrio.core.io.ResourceResponse. The reading system may call those from any thread, and from more than one at once, so they must be thread safe.

The callback-style overloads invoke their onSuccess and onError callbacks on the main thread.

Loading publications

Call loadEpub or loadPdf to load a publication into the ReadingSystemEngine. The returned ReaderPublication can be used with the readerView to render content.

Engine Events

The reading system lets you listen and react to events. This can for example be, the user clicking a link or an image, or a ReaderView navigating to the next page.

You can use the various add event listener methods on the framework classes such as the ReaderView.

Properties

Link copied to clipboard

Gets the API that can be used for searching in ReaderDocuments.

Link copied to clipboard
Link copied to clipboard
abstract val readerView: ReaderView

The ReaderView is responsible for everything related to presentation and navigation of publication contents.

Link copied to clipboard

All SyncMediaPlayer instances created using this ReadingSystemEngine.

Functions

Link copied to clipboard
abstract suspend fun createSyncMediaPlayer(colibrioAudioPlayer: ColibrioAudioPlayer): ColibrioResult<SyncMediaPlayer>

Creates a new SyncMediaPlayer from an existing ColibrioAudioPlayer.

abstract fun createSyncMediaPlayer(timeline: SyncMediaTimeline, options: SyncMediaPlayerInitOptions = SyncMediaPlayerInitOptions()): ColibrioResult<SyncMediaPlayer>

Creates a new SyncMediaPlayer. Use for playing synchronized media such as EPUB Media Overlays or TTS (Text-To-Speech). You can create SyncMediaTimeline instances from publications using the format specific ReaderPublication instances. For example EpubReaderPublication.createMediaOverlaySyncMediaTimeline() or PdfReaderPublication.createTtsSyncMediaTimeline()`.

Link copied to clipboard

Destroys a SyncMediaPlayer created using this ReadingSystemEngine. Throws an error if the SyncMediaPlayer was not created using this ReadingSystemEngine.

Link copied to clipboard
abstract fun loadEpub(config: EpubResourceProviderLoadConfig, onSuccess: (EpubReaderPublication) -> Unit, onError: (ColibrioException) -> Unit)

Loads an EPUB file into the ReadingSystemEngine.

Link copied to clipboard
abstract fun loadPdf(config: PdfRandomAccessDataSourceLoadConfig, onSuccess: (PdfReaderPublication) -> Unit, onError: (ColibrioException) -> Unit)

Loads a PDF file into the ReadingSystemEngine.

Link copied to clipboard
abstract fun unloadPublication(readerPublication: ReaderPublication)

Unloads readerPublication from the reading system. readerPublication must have been loaded using this ReadingSystemEngine instance, and its readerDocuments must not currently be in use by readerView.