But knowing what overlays are and how they can enhance ebooks doesn’t get us any closer to understanding how they work and the considerations involved in making them, which is the real goal for this section. If you like to believe in magic, though, here’s an early warning that by the end it won’t seem all that fantastic how your reading system makes words and paragraphs highlight as a voice narrates the text. Prepare to be disappointed that your reading system doesn’t have superpowers.
To begin moving under the hood of an EPUB, though, the first thing to understand is
that overlays are just specialized xml documents that contain the instructions a
reading system uses to synchronize the text display with the audio playback. They’re
expressed using a subset of SMIL that we’ll cover as we move along, combined with
the epub:type attribute we ran into earlier for
semantic inflection.
The order of the instructions in the overlay document defines the reading order for the ebook when in playback mode. A reading system will move through the instructions one at a time, or a reader can manually navigate in similar fashion to how assistive technologies enable navigation through the markup (i.e., escaping and skipping).
As a reading system encounters each synchronization point, it determines from the
provided information which element in which content file has to be loaded (by its
id) and the corresponding position in the audio
track at which to start the narration. The reading system will then load and
highlight the word or passage for you at the same time that you hear the audio
start. When the audio track reaches the end point you’ve specified—or the end of the
audio file if you haven’t specified one—the reading system checks the next
synchronization point to see what text and audio to load next.
This process of playback and resynchronization continues over and over until you reach the end of the book, giving the appearance to the reader that their system has come alive and is guiding them through it.