Ambient Soundtrack

To add an ambient soundtrack to your book, include an audio element with the attribute epub:type="ibooks:soundtrack" and include both the xmlns:epub namespace and the epub:prefix="ibooks:" namespace (see the code example below).

Note: It is best to have a single soundtrack throughout the entire book. If you define a new soundtrack for each spread, know that there is a delay between when the previous soundtrack ends and the new soundtrack starts.

Ambient Soundtrack Example

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"epub:prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/">... <audio epub:type="ibooks:soundtrack" src="audio/sonata14.m4a"/>...</html>

Note: In the prefix example above, the space between ibooks: and http:// is important; it needs to be a single, regular space character and not a return, non-breaking space, or any other kind of whitespace.

If you have a single soundtrack that is intended for the entire book, include the same audio file in every XHTML document. Apple Books will play this soundtrack seamlessly across documents. This audio file will play on a loop.

For ideal performance, use CSS to place soundtrack audio outside of the page boundary.

audio { position: absolute; top: -30px;}