Colibrio Reader Framework API - Cloud license
    Preparing search index...

    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.

    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.
    interface IReadingSystemEngine {
        addEngineEventListener<T extends keyof IEngineEventTypeMap>(
            type: T,
            listener: IEngineEventListener<IEngineEventTypeMap[T]>,
        ): void;
        addFormatAdapter(formatAdapter: IFormatAdapter): void;
        createReaderView(options?: IReaderViewOptions): IReaderView;
        createSyncMediaPlayer(
            timeline: ISyncMediaTimeline,
            options?: ISyncMediaPlayerInitOptions,
        ): ISyncMediaPlayer;
        destroy(): void;
        destroyReaderView(readerView: IReaderView): void;
        destroySyncMediaPlayer(player: ISyncMediaPlayer): void;
        getEngineEventListeners<T extends keyof IEngineEventTypeMap>(
            type: T,
        ): IEngineEventListener<IEngineEventTypeMap[T]>[];
        getFrameworkVersion(): string;
        getOptions(): DeepRequired<IReadingSystemEngineOptions>;
        getReaderDocumentSearch(): IReaderDocumentSearch;
        getReaderPublications(): IReaderPublication[];
        getReaderViewByName(name: string): IReaderView;
        getReaderViews(): IReaderView[];
        getSyncMediaPlayerByName(name: string): ISyncMediaPlayer;
        getSyncMediaPlayers(): ISyncMediaPlayer[];
        isDestroyed(): boolean;
        loadPublication(
            publication: IPublication,
            options?: Partial<IReaderPublicationOptions>,
            licenseOptions?: IReadingSessionOptions,
        ): Promise<IReaderPublication>;
        removeEngineEventListener<T extends keyof IEngineEventTypeMap>(
            type: T,
            listener: IEngineEventListener<IEngineEventTypeMap[T]>,
        ): void;
        unloadPublication(readerPublication: IReaderPublication): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Methods

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

      Parameters

      Returns void

    • 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

    • Destroys this instance, including any ReaderView, SyncMediaPlayer, ReaderPublication instances created using this ReadingSystemEngine.

      Returns void

    • 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

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

      Parameters

      Returns void

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

      Returns string

    • 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.

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

      Returns IReaderView[]

    • 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.

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

      Returns boolean

    • Load a publication into this ReadingSystemEngine.

      Parameters

      • publication: IPublication

        The publication to load

      • Optionaloptions: Partial<IReaderPublicationOptions>

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

      • OptionallicenseOptions: 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.

    • Unloads a publication previously loaded with loadPublication().

      Parameters

      Returns void