Video Events

How can I handle video events in the script?

For example, when new chapter started. Or when certain frame reached.

[152 byte] By [Polina] at [2008-3-5]
# 1

Listen to the chapter event for chapter changes -- if you have the spec, the events are defined in Z.6.2-1

Example code:

addEventListener("chapter", handleChapter, false);

function handleChapter(evt)
{
var oldChapter = evt.oldValue;
// int or NaN if no previous chapter
var newChapter = evt.newValue;
// int of new chapter number

// do something useful...
}

For knowing when certain frames are reached, you can either use scheduled events (in the playlist) or you can have cues in the markup bound to the title clock that fire events on a given frame.

PeterTorr-MSFT at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 2

For stopping at certain frames, here is a bit of playlist:

<ScheduledControlList>
<Event id="Capture" titleTime="00:01:30:00" />
</ScheduledControlList>

and here is some Script to handle it (which pauses, captures the video frame, then resumes):

application.addEventListener( "scheduled_event", OnScheduledEvent, false )

function VideoMainCaptureCallback(i,uri)
{
Player.playlist.play();
}

function PlayerVideoMainCapture(filename)
{
try
{
Player.video.main.capture(filename,VideoMainCaptureCallback);
}
catch (ex)
{
}
}


function OnScheduledEvent(evt)
{
if (evt.id == 'Capture')
{
Player.playlist.pause();
PlayerVideoMainCapture("
file:///filecache/test.cvi");
}
}

AndyPennellMSFT at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 3
I'm confused.

try
{
Player.video.main.capture(filename,VideoMainCaptureCallback);
}

Shouldn't it be:

try
{
Player.video.main.capture(filename, VideoMainCaptureCallback(int status, String uri));
}

To match the signature specified in Z.10.19.3?

And also, I don't understand why the interface for that callback. Why pass the uri and status?

wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 4

try

{

Player.video.main.capture(filename,VideoMainCaptureCallback);

}

is the correct one.

VideoMainCaptureCallback is the callback function. No need of passing parameters as this function is called internally.

function VideoMainCaptureCallback(status,uri)
{
// you can use status and uri to check whether captured image is stored

//in respective uri successfully or failed

if(status == Player.Finished)

{

//capture succeeded

}

Player.playlist.play();

}


bharathi_tunes at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 5
Andy Pennell MSFT wrote:

For stopping at certain frames, here is a bit of playlist:

<ScheduledControlList>
<Event id="Capture" titleTime="00:01:30:00" />
</ScheduledControlList>

and here is some Script to handle it (which pauses, captures the video frame, then resumes):

application.addEventListener( "scheduled_event", OnScheduledEvent, false )

function VideoMainCaptureCallback(i,uri)
{
Player.playlist.play();
}

function PlayerVideoMainCapture(filename)
{
try
{
Player.video.main.capture(filename,VideoMainCaptureCallback);
}
catch (ex)
{
}
}


function OnScheduledEvent(evt)
{
if (evt.id == 'Capture')
{
Player.playlist.pause();
PlayerVideoMainCapture("
file:///filecache/test.cvi");
}
}

I tried a simple version of this and cannot get it to work. No pause at 10 seconds.

## js ##

function OnScheduledEvent(evt) {
if (evt.id == "ev1") {
Player.playlist.pause();
}
}
addEventListener("ScheduledEvent", OnScheduledEvent, false);

## playlist ##

<Title titleNumber="3" titleDuration="00:04:18:00" id="greenday" displayName="Green Day" onEnd="robthomas">
<PrimaryAudioVideoClip titleTimeBegin="00:00:00:00" titleTimeEnd="00:04:17:00"
src="file:///dvddisc/HVDVD_TS/GreenDay_AmericanIdiot_700.wmv" dataSource="Disc">
<Video track="1" />
<Audio track="1" streamNumber="1" />
</PrimaryAudioVideoClip>
<ChapterList>
<Chapter titleTimeBegin="00:00:00:00" />
</ChapterList>
<ScheduledControlList>
<Event id="ev1" titleTime="00:00:10:00" />
</ScheduledControlList>
</Title>

wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 6
Can someone verify that the iHDSim recgonizes video events? I've got a very simple implementation, it seems to follow the spec, yet it isn't working.
wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 7

It needs to be "scheduled_event", not "ScheduledEvent" in your AddEventListener?

BryanKilian-MSFT at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 8
I will try that.

What's odd is I just ran the HDValidator and it complains the ScheduledControlList is not an allowed Element for Title! However the spec clearly says it is. I will post this question in a new thread.

wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 9
Bryan Kilian - MSFT wrote:

It needs to be "scheduled_event", not "ScheduledEvent" in your AddEventListener?

Ok that was it - THANKS!

But why? Where in the spec does it define the name of the scheduled event parameter?

Table 8.3.1-1 just calls it "Scheduled".

wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 10

It's in Z.6.2-1, the column labeled "Value" is the one you want.

BryanKilian-MSFT at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...
# 11
Awesome! Thanks.

I must have thumbed over that small section a dozen times this afternoon ;)

wmerydith at 2007-8-30 > top of Msdn Tech,Audio and Video Development,HD DVD Interactivity Authoring...