Hello World, Part 4: Script and a Movie! [Part i: The Playlist]

Hello World, Part 4: Script and a Movie! [Part i: The Playlist]

  • Comments 5

Now comes the exciting part -- actually interacting with a movie -- and the doubly-exciting part: you can now follow along with me at home!

But first, let's get to the answer to the last part's question: why couldn't we end the cue on a focused-blue-button? And let my just say that I was appalled by the number of guesses I received -- exactly zero! Come on, you can do better than that! :-)

Anyway, the answer is this: We can't end the cue on a focused-blue-button because that's what triggers the begin of the cue. And we can't change the begin to be a non-focused-red-button because no buttons are red until the cue fires. So we have to leave it at starting on a focused-blue-button and ending on a non-focused-red-button.

There's also a slight problem with this approach: if the user hits the remote keys very fast, the highlight system can break down due to the way 'ticks' are processed in iHD. But we'll cover that another day.

OK, moving swiftly on, here's the new code for today's sample. Bonus: The code for this sample (along with the previous three "Hello World" samples) is available as a ZIP file. Note that after extracting each ZIP file, you will need to copy some existing files into the right folders (basically font and WMV files) in order to make them work. These samples should all play with the Jumpstart you can download from the URL above.


First, a new file: the playlist. All HD DVD titles require a playlist, but I haven't shown it to you yet since it was largely uninteresting for the first few samples. A playlist defines a "session" (for want of a better word) in HD DVD -- when you insert a disc, the player finds an appropriate playlist and loads it. The playlist controls the player and lists all the resources it will need until you turn it off, eject the disc, or the script code on the disc programmatically executes another playlist (eg, one it has downloaded from the internet).

Note that your playlist must be called VPLSTxxx.XPL (where xxx is a number from 000 to 999) and it must be all upper-case. HD DVD is case-sensitive for filenames.

Anyway, here's what a simple sample looks like for Part 4:

<? xml version = " 1.0 " encoding = " UTF-8 " ?>

< Playlist xmlns = " http://www.dvdforum.org/2005/HDDVDVideo/Playlist " majorVersion = " 1 " minorVersion = " 0 " >


  < Configuration >

    < StreamingBuffer size = " 0 " />

    < Aperture size = " 1920x1080 " />

    < MainVideoDefaultColor color = " 705040 " />

  </ Configuration >


  < MediaAttributeList />


  < TitleSet timeBase = " 60fps " defaultLanguage = " en " >


    < Title titleNumber = " 1 " titleDuration = " 00:00:20:00 " id = " Intro "

      displayName = " Intro " onEnd = " Intro " >


      < PrimaryAudioVideoClip titleTimeBegin = " 00:00:00:00 "

        titleTimeEnd = " 00:00:20:00 "

        src = " file:///dvddisc/HVDVD_TS/movie.wmv " dataSource = " Disc " >


        < Video track = " 1 " />

        < Audio track = " 1 " streamNumber = " 1 " />

      </ PrimaryAudioVideoClip >


      < ChapterList >

        < Chapter titleTimeBegin = " 00:00:00:00 " />

        < Chapter titleTimeBegin = " 00:00:05:00 " />

        < Chapter titleTimeBegin = " 00:00:10:00 " />

      </ ChapterList >

    </ Title >


    < PlaylistApplication description = " Test " language = " en "

      src = " file:///dvddisc/ADV_OBJ/Manifest.xmf " >


      < PlaylistApplicationResource multiplexed = " false "

        size = " 500000 " src = " file:///dvddisc/ADV_OBJ/Manifest.xmf " />


      < PlaylistApplicationResource multiplexed = " false "

        size = " 500000 " src = " file:///dvddisc/ADV_OBJ/Script.js " />


      < PlaylistApplicationResource multiplexed = " false "

        size = " 500000 " src = " file:///dvddisc/ADV_OBJ/Markup.xmu " />

    </ PlaylistApplication >

  </ TitleSet >

</ Playlist >


This file basically tells HD DVD that there is a 20-second movie clip named "movie.wmv" and that there are some resources it should load to display an application. Playlists can get quite long when you include all the information for every title on the disc (FBI Warning, trailers, main movie, deleted scenes, etc.) but they really don't get very complicated.

Looking at the Elements

This will be a very quick look at the elements. Personally I don't mess with playlists too much (I tend to use the same playlist for all my iHD code, with the same background video playing) and I don't have the HD DVD spec with me, so some of this will be off the top of my head.


The Playlist element is just the root of the file. Nothing too interesting here except the namespace.


The Configurartion element tells the player how to configure video playback for this playlist.


The StreamingBufferSize element tells the player how much of its memory to reserve for streaming audio / video data from the internet. Since we're not going to be streaming any content in this sample, it is zero. Because HD DVD discs need to play back on a variety of devices (from expensive PCs with gigabytes of RAM to cheap set-top boxes with minimal hardware), the HD DVD specification provides details about how much memory a player must have, and disc authors need to be careful with how they use that memory. I won't go into that in detail right now, but (in theory) the iHDSim program will fail to load your disc if you use up too much memory.


Not just an image-editing program from Apple, Aperture is also an element that tells the player how much screen real-estate the playlist will use -- 1280 x 720 or 1920 x 1080. Note that the player will automatically scale these values correctly for different TV sets (eg, a 1080 playlist will still display on a 720 monitor), so you will typically choose 1920 x 1080 unless you only have 720 content.


The MainVideoDefaultColour element is the colour to display if the main video has been scaled to not fill the full aperture. Typically you won't care about this value because you will have video filling the full screen, but in this case I have made it green. (Note that the colour is not specified in the familiar in RGB format; it is specified in the YUV colour space).


The MediaAttributeList is not used here. It would typically be used to store attributes about you audio / video clips that could then be referenced later on. Attributes include things such as the codec used, number of channels of audio, and so on.


The TitleSet element defines all the titles in the playlist. A "title" is a linear path through a set of media files. Typically, titles would be things like the main move, the deleted scenes, a making-of documentary, and so on. Here we set the timeBase to be 60 frames per second, which would be typical for North American usage. We also set the defaultLanguage to be English ("en") which is used to choose other resources later on (like which applications to load).


The Title element specifies the resources needed for a particular title (the movie, the deleted scenes, etc.) Typically this will include one or more "primary" video files; possibly some "secondary" video files (for picture-in-picture); chapter mark information; subtitles; and possibly some specific per-title applications. We give the title a titleDuration (using the timecode notation of hours:minutes:seconds:frames), a titleNumber, an id and displayName, and an onEnd attribute which is the id of the title to play when this one ends (which, in this case, is set to loop back on itself).


The PrimaryAudioVideoClip element defines one of the files used to make up the title. In this case, the title consists of a single file, but it could consist of several different files. For example, if there were two versions of a movie on a disc -- the "normal" version and the "extended" version -- each would be its own Title and you would break the movie up several chunks. The two titles would share the chunks that were the same in both versions, and swap out the "normal" or "extended" scenes only where they differ. This would save on disc space, since you don't have to have two whole copies of the movie.

The clip has both titleTimeBegin and titleTimeEnd attributes, and these correspond to where on the overall title timeline the video should be played. For a simple title with only one clip, the start is 00:00:00:00 and the end is the length of the clip. The dataSource of the file is also specified (in this case, the optical disc) and also the src URI of the file -- in this case, a WMV file.

Two things to note about the src attribute:

1. Because iHDSim only supports running Windows Media files, this attribute is pointing to a WMV file. For a real disc, this would point to a different kind of file.

2. Nevertheless, iHDSim fully simulates the filesystem structure of the HD DVD player, and so the URI is specified as it will appear on the final disc (ie, you don't put in "C:\Documents and Settings\ptorr\My Documents\video.wmv" or anything like that).

Video and Audio

The Video and Audio elements describe which of the various tracks inside the video file should be used. Within a given file, you can multiplex several different tracks (for example, English, French, Dolby, and DTS audio) and then later you can switch between them. I don't pretend to know much about this aspect of the playlist though :-).


The ChapterList element is just a container for chapter markers.


The Chapter elements use the titleTimeBegin attribute to specify at what point in the title the chapter starts. You can then jump to the chapter using the navigation buttons on your remote, or by using the chapter buttons on the menu (which end up calling APIs inside the player).


The PlaylistApplication element describes an application that will run for the entire duration of the playlist. Contrast this to a normal application (also called a "title application") that only runs within a given title. The playlist application allows you to build your main navigation menu (eg, the menubar on any of the Warner Bros. titles) that is available at all times. It has a description, a language, and a src that points to a manifest file (see below). Note again that we use "real" HD DVD paths, not Windows filesystem paths.


The PlaylistApplicationResource elements list all the resources needed for the application -- markup files, script files, images, sounds, and so on. Because of the way optical discs work, you can't really do random disc access while the movie is playing. Instead, you need to load all your resources up-front (or multiplex them into the main video stream) so that the laser isn't interrupted while it's trying to read the movie off the disc. Here we specify the src to the resource, its size (which we over-estimate during development, but you should put the real size in before burning a disc), and whether or not it is a stand-alone file or multiplexed into the video stream.

Moving Swiftly On...

Phew! That's it for the playlist... and that's only a simple one. They can get much more complicated than that for a real disc with many titles and different audio tracks, subtitles, applications, etc.

Next, we will look at the markup file.

  • Do you have this sample zipped up for download and use?  I'd like set it up and play with it.

  • There is a link in the 5th paragraph :-)

  • You mean the one in bold!  <blush>
  • In the chapter list element there are 3 chapters defined.  All with different times but I expected them to be given unique ids.  Why is that not the case?
  • I don't think chapters need IDs, since you can jump to them by index. The IDs might be useful for smoething else, but I'm at home without a copy of the spec right now so I can't say for sure ;-)
Page 1 of 1 (5 items)