Adding a SMIL File and Audio File to an EPUB

SMIL documents and audio files must be included in the manifest of the OPF. In addition to listing the SMIL and narrative audio files, a SMIL document must be cross-referenced with its corresponding XHTML document by including the media-overlay attribute on the XHTML document. The media-overlay attribute has a value equal to the id name of the corresponding SMIL document.

Important: Make sure you specify the correct media-type for your audio files in the OPF (the expected media-type for m4a files is "audio/m4a"). If the media-type is incorrect, the audio will not play after customers have purchased the book. This issue will not be evident when testing locally prior to delivering to Apple Books.

Manifest Example

<manifest> ... <item id="page1" href="page1.xhtml" media-type="application/xhtml+xml" media-overlay="mo-page1"/> <item id="audio1" href="page1.smil" media-type="application/smil+xml"/> <item id="narrat" href="audio/page1.m4a" media-type="audio/m4a"/> ...</manifest>

Media Duration

The package document must include the duration of each media overlay as well as of the entire book. The refines attribute references the ID of the corresponding SMIL document.

For example:

<package> <metadata xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" > . . . <meta property="media:active-class">-epub-media-overlay-active</meta> <meta property="media:duration">0:00:48</meta> <meta property="media:duration" refines="#moPage001">0:00:03</meta> <meta property="media:duration" refines="#moPage002">0:00:06</meta> <meta property="media:duration" refines="#moPage003">0:00:06</meta> <meta property="media:duration" refines="#moPage004">0:00:05</meta> <meta property="media:duration" refines="#moPage005">0:00:15</meta> <meta property="media:duration" refines="#moPage007">0:00:12</meta> . . . </metadata>