Picture-in-Picture (PIP) is one of those "cool" features in HD DVD that looks really difficult but is really easy to do -- contrast that with so many other things that look simple or are taken for granted, but take forever to implement... That's not to say it's easy for the player manufacturer to support simultaneous decoding of two video streams, but it's easy for the HD DVD interactivity author to program it :-). Good thing for us that the secondary decoder is a mandatory part of HD DVD, so player manufacturers can't skimp on the feature even if it is hard to do.
Anyway, adding PIP is easy. Right now, only synchronous PIP is supported (that is, the PIP is multiplexed in with the normal video and plays / pauses at the same time as the main video). Asynchronous PIP is also defined (where the PIP can play independently of the main video), but not yet supported in iHDSim.
Note that PIP is also known as "Sub Video" or "Secondary Video" because, well, it's the second video stream. (Note though that Secondary Video can also contain Substitute Video -- different from Sub Video -- that is full-screen HD content). You might also hear it called "IME" which is Warner Bros.' name for the "In-Movie Experience", but the IME is a much larger set of functionality than just PIP. It's also Warner's name, not HD DVD's.
Anyway, adding PIP is easy. First you define your PIP video stream in the playlist:
<Title titleNumber="1" titleDuration="00:01:21:00" id="main" onEnd="main">
<PrimaryAudioVideoClip titleTimeBegin="00:00:00:00" titleTimeEnd="00:01:21:00"
<Video track="1" />
<SecondaryAudioVideoClip titleTimeBegin="00:00:00:00" titleTimeEnd="00:01:21:00"
src="file:///dvddisc/HVDVD_TS/PIP.MAP" sync="hard" dataSource="Disc">
<SubVideo description="PiP Track" track="1" />
<!-- Chapters go here... -->
</ Title >
In addition to the normal PrimaryAudioVideoClip, you add a SecondaryAudioVideoClip that points to the secondary video set. In this case, I am just using to WMV files that I have re-named to MAP files so that iHDSim will work correctly. Note the sync="hard" attribute which tells the player this is synchronous video (and, indeed, it would have to be, since it is also playing off the shiny disc, and you can't play two different clips off the disc at the same time unless they're multiplexed together -- you've only got one laser to work with :-)).
So the next thing to do is to turn the PIP on, which is a simple API call (although, as noted above, iHDSim might butcher some of the parameters). Here's something you might use to implement it; this will turn the PIP on or off every time it is called:
var isPiPVisible = false ;
// Show the PiP if it's showing, or hide it if it's not
var sub = Player.video.sub;
if (isPiPVisible == true )
// Hide the PIP if it was visible
sub.alpha = 0;
// Play the movie if it is currently paused
// You can't show the PIP if video is paused
var playlist = Player.playlist;
if (playlist.playState != playlist.PLAYSTATE_PLAY)
// TODO: iHDSim currently doesn't calculate the crop size of the sub video
// correctly; it appears to be relative to the main canvas, not to the actual
// size of the secondary video
var x = 200;
var y = 200;
var scale = Player.createVideoScale(1,4);
var clipx = 0;
var clipy = 0;
var clipWidth = 1920;
var clipHeight = 1280;
var transition = "00:00:00:01" ;
sub.changeLayout(x, y, scale, clipx, clipy, clipWidth, clipHeight, transition);
sub.alpha = 1;
isPiPVisible = !isPiPVisible;
And that's it! Easy, huh?