Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Loading publications

The ReadingSystemEngine does not know about any publication formats initially. You need to use addFormatAdapter() to add support for a specific publication format. Call loadPublication() to load a source publication into the ReadingSystemEngine. The returned ReaderPublication can be used with ReaderViews to render content.

Engine Events

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

You can addEngineEventListener() on for example ReadingSystemEngines and ReaderViews. The reading system uses an event model that is similar to native browser events. Thus, you will find that most properties and methods from the native browser events also exist in the IEngineEvent interface. Just like browser events, EngineEvents bubbles from the deepest event target and upwards.

example

let engine = new ReadingSystemEngine({ licenseApiKey: 'my-license-api-key'}); engine.addFormatAdapter(new EpubFormatAdapter()); let readerPublication = await engine.loadPublication(epubOcf.getDefaultPublication()); let readerView = engine.createReaderView(); readerView.setReaderDocuments(readerPublication.getSpine()); // See ReaderView docs for how to continue setting it up.

Hierarchy

Implemented by

Index

Methods

addEngineEventListener

addFormatAdapter

  • Adds support for a specific publication format. Format adapters implemented by Colibrio can be found in colibrio.readingsystem.format

    Parameters

    Returns void

createReaderView

  • Creates a new ReaderView that can render content from publications loaded by this engine.

    Parameters

    Returns IReaderView

createSyncMediaPlayer

  • 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 IPdfReaderPublication.createTtsSyncMediaTimeline().

    A SyncMediaPlayer can play media with or without being attached to a ReaderView. If attached to a ReaderView using readerView.setSyncMediaPlayer() the ReaderView and SyncMediaPlayer can synchronize their positions. This enables features such as text highlighting and automatic page turning.

    Parameters

    Returns ISyncMediaPlayer

destroy

  • destroy(): void
  • Destroys this instance, including any ReaderView, SyncMediaPlayer, ReaderPublication instances created using this ReadingSystemEngine.

    Returns void

destroyReaderView

  • Destroys a ReaderView and its annotation layers, releasing any underlying resources used by the ReaderView and the activeRenderer. This will also remove all EngineEvent listeners that have been added to the ReaderView.

    Parameters

    Returns void

destroySyncMediaPlayer

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

    Parameters

    Returns void

getEngineEventListeners

getEventBus

  • Get the event bus used for emitting events.

    To listen to events emitted by this ReadingSystemEngine, use addEngineEventListener().

    Returns IEngineEventBus

getFrameworkVersion

  • getFrameworkVersion(): string
  • Get the semver version of the Colibrio Reader Framework. For example: "2.0.0-rc.1"

    Returns string

getOptions

getReaderDocumentSearch

getReaderPublications

  • Get all reader publications that have been loaded by this ReadingSystemEngine.

    Returns IReaderPublication[]

getReaderViewByName

  • Get a ReaderView that was created using this ReadingSystemEngine by name.

    Parameters

    • name: string

    Returns IReaderView

    The ReaderView instance if one with that name exists.

getReaderViews

  • Get all ReaderView instances that was created using this ReadingSystemEngine.

    Returns IReaderView[]

getSyncMediaPlayerByName

  • Get a SyncMediaPlayer that was created using this ReadingSystemEngine by name.

    Parameters

    • name: string

    Returns ISyncMediaPlayer

    The SyncMediaPlayer instance if one with that name exists.

getSyncMediaPlayers

  • Get all synchronized media players that have been created using this ReadingSystemEngine.

    Returns ISyncMediaPlayer[]

isDestroyed

  • isDestroyed(): boolean
  • If destroy() has been called on this instance.

    Returns boolean

loadPublication

  • Load a publication into this ReadingSystemEngine.

    Parameters

    • publication: IPublication

      The publication to load

    • Optional options: Partial<IReaderPublicationOptions>

      Options related to processing and presentation of the publication. See the format adapter documentation for format specific options.

    • Optional licenseOptions: IReadingSessionOptions

      Required if using the Colibrio Cloud License SDK.

    Returns Promise<IReaderPublication>

    A Promise resolved with a ReaderPublication instance if the publication is successfully loaded. Rejected if no format adapter is able to handle the publication format. Rejected if the publication is invalid or contained errors that were not possible to recover from.

removeEngineEventListener

setOptions

  • Set new ReadingSystemEngineOptions. Existing properties are preserved if they are not defined in the passed options object. Properties explicitly set to undefined will be restored to their default values.

    Parameters

    Returns void

unloadPublication

  • Unloads a publication previously loaded with loadPublication().

    Parameters

    Returns void

Generated using TypeDoc