Using Flash video in ePub

by Liza Daly

Since Bookworm has support for video you may want to experiment with creating your own video ebooks. Here’s how to do it and still create a valid XHTML 1.1/ePub.

Assuming you have a Flash movie called Creative_Commons_-_Get_Creative.swf and a containing XHTML page called chapter-1.html, put this in your OPF:

    <!-- Flash video -->
    <item id="video"
          href="chapter-1.html"
          media-type="application/xhtml+xml"/>

    <item id="video-flash"
          href="Creative_Commons_-_Get_Creative.swf"
          fallback="video-fallback"
          media-type="application/x-shockwave-flash"/>

The first item is a standard OPS document; the second is the Flash movie itself. Notice that we declared a fallback to another item. That item needs to be a supported type, like an image:

    <item id="video-fallback"
          href="getcreative.gif"
          media-type="image/gif"/>

Then we need to create the XHTML document, including the Flash movie. The document should be valid XHTML 1.1, which precludes using many of the boilerplate Flash code available on the web which is meant to support IE or other legacy browsers. This code is valid and works in Bookworm (under Firefox):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Flash video test</title>
  </head>
  <body>
    <p>
      <object type="application/x-shockwave-flash" data="Creative_Commons_-_Get_Creative.swf" width="300" height="400">
        <param name="movie" value="Creative_Commons_-_Get_Creative.swf" />
        <img src="getcreative.gif" alt="banner" />
      </object>
    </p>
  </body>
</html>

Notice the implicit fallback img as well.

Try out the video demo, which works in Bookworm and Adobe Digital Editions. The ePub is released under a Creative Commons Attribution license.

Edited November 15, 2009 to provide a working version in Adobe Digital Editions; thanks Dave Cramer.