Inside Macintosh: QuickTime Reference

| Previous | Chapter Contents | Chapter Top | Next |

Support for Data URLs

QuickTime 4.1 now provides support for the "data:" URL scheme. You can avoid the overhead of a separate HTTP transaction for small files by embedding the data directly into the SMIL file using a data URL instead. The specification for this scheme is available at:

<http://www.ietf.org/rfc/rfc2397.txt>

URLs are of the form:

data:[<mediatype>][;base64],<data>

A number of applications can Base64 encode files; a useful one is MPack, which is available free at:

<ftp://ftp.andrew.cmu.edu/pub/mpack/>

An example SMIL document that uses the "data:" scheme is shown in Listing 3.

Note that these data URLs cannot have line breaks in them, though they are printed that way to fit on a page in Listing 3.

Listing 3  Usage of the "data:" scheme, producing a GIF image

<!--DOCTYPE smil PUBLIC    "-//W3C//DTD SMIL 1.0//EN"
    "http://www.w3.org/TR/REC-smil/SMIL1.0.dtd">-->
<smil>

    <head>
        <layout>
            <region id="j" width="64" height="64" fit="fill" />
        </layout>
    </head>

    <body>
            <img 
src="data:image/gif;base64,R0lGODlhIAAgAJEAAP///
5mZmWZmZgAAACH5BAAAAAAALAAAAAAgACAAAAKrnH8iEeAPmAwCWbum1ur6sYVS9yGZ9IhUmZwNFG0Vq7gvJM/
fYpOVNNdMr3Mj6GgCDHIURKFDC5boSdQWdupqs6SbUsBejep3Gj3xcnOnhq5fEW2le9jfDV019dydAjOAHAyRaWhBiVBk2YnomjDCMTDAvK4
JaloqEI0uXilNznAA8YBChJmGEMKOjIBmFja8JfK5pU0iwJJaOJ2K6KLYdsbyRLlE+H6e1AAADs=" dur="5s" region="j" />
    </body>

</smil>

The SMIL document shown in Listing 4 lets you create a simple text display, using text descriptors, as described at

<http://www.apple.com/quicktime/authoring/importtext.html>.

Listing 4  A simple text display using text descriptors

<!--DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 1.0//EN"
        "http://www.w3.org/TR/REC-smil/SMIL1.0.dtd">-->


<smil>

        <head>
                <layout>
                        <region id="j" width="160" height="48" fit="fill" />
                </layout>
        </head>

        <body>
                        <img
src="data:text/plain,{QTtext}{font:Helvetica}{bold}{keyedText:on}{size:14}
{textColor:65535,19007,19791}{justify:center}{width:160}{height:48}{language:0}%0d%0d[00:00:0 
0.000]%0dTheamazing%0dQuickTime%0d[00:00:04.000]" dur="4s" region="j" />
        </body>

</smil>

© 2000 Apple Computer, Inc.

Inside Macintosh: QuickTime Reference

| Previous | Chapter Contents | Chapter Top | Next |