Eyeframe

Hi guys,

i'm very new to this HD DVD authoring. I'm doing my first title and have run across a problem. I'm trying to track whatever chapter i am in during the main feature title then highlight the specific chapter button when Top Menu is pressed. How can I store a variable of what chapter i'm on. So far i've been trying the following in script......

function sceneTrackHandler()

{

var chapID = Player.playlist.currentChapterNumber;

Player.generalParameters.setValue("sceneID", sceneID);

traceInfo(sceneID ,"sceneID");

}

I'm using markup to call the sceneTrackHandler when the TOP_MENU is pressed which then switches to the scenes page and calls the setScenesHandler in the pageLoadedHandler

function setScenesHandler(pageName)

{

var chapter = getData("chapID");

switch(chapter)

{

case "0":

var id = "scene_1";

break;

case "1":

var id = "scene_2";

break;

case "2":

var id = "scene_3";

break;

case "3":

var id = "scene_4";

break;

default:

var id = "none";

break;

}

if (id == "none")

{

if (pageName == "file:///dvddisc/ADV_OBJ/blah/blah.xmu")

{

var id = "scene_1";

}

}

traceInfo(id ,"setting focus");

document.getElementById(id).state.focused = "true";

document.getElementById(id).state.unsetProperty("focused");

Player.generalParameters.setValue("sceneID", "initted");

}

I know the setScenesHandler is working, as if I set the chapID on a button press event it works fine. The problem seems to be the sceneTrackHandler storing the chapter number. Any suggestions would be hugely appreciated.



Re: HD DVD Interactivity Authoring Scene Tracking

Shital14

You might want to replace sceneID with chapID in function sceneTrackHandler()

Hopefully that works!

Player.generalParameters.setValue("sceneID", sceneID);

Player.generalParameters.setValue("sceneID", chapID);

traceInfo(sceneID ,"sceneID");

traceInfo(chapID ,"sceneID");

function sceneTrackHandler()

{

var chapID = Player.playlist.currentChapterNumber;

Player.generalParameters.setValue("sceneID", chapID);

traceInfo(chapID ,"sceneID");

}





Re: HD DVD Interactivity Authoring Scene Tracking

Clinic

Yes, SceneTrackHandler is reading the currentChapterNumber into var chapID, but then storing the variable sceneID into the generalParameter (which may or may not be null).






Re: HD DVD Interactivity Authoring Scene Tracking

Denny B

Hi EyeFrame,

Are you setting up your application as a Play list Application If so I'd recommend using more event handlers and global variables to store information. You can do this in both markup and all script depending on your choice.

Then as a general rule you don't have to consistently declare your variables you can write your script for the setScenesHandler function like this:

//-------------------------------------------------------------------------------------------------------------------------

var sceneID = null;

function setScenesHandler(pageName)

{

//Since id is requird below we can set the defualt here and declare it at the same time.

var id = "none";

var chapter = getData("chapID");

switch(chapter)

{

case "0":

id = "scene_1";

break;

case "1":

id = "scene_2";

break;

case "2":

id = "scene_3";

break;

case "3":

id = "scene_4";

break;

}

if (id == "none")

{

if (pageName == "file:///dvddisc/ADV_OBJ/blah/blah.xmu")

{

id = "scene_1";

}

}

traceInfo(id ,"setting focus");

document.getElementById(id).state.focused = "true";

document.getElementById(id).state.unsetProperty("focused");

Player.generalParameters.setValue("sceneID", "initted");

//Using a global variable can be used anywere by any function and/or object as long as the same application is loaded.

sceneID = "initted";

}

//-------------------------------------------------------------------------------------------------------------------------

Good luck.

Denny B.






Re: HD DVD Interactivity Authoring Scene Tracking

Amy Dullard - MSFT

The problem is that you are capturing the value in a variable called chapID, but then setting the value with a variable called sceneID

function sceneTrackHandler()

{

//old line

//var chapID = Player.playlist.currentChapterNumber;

//new line

var sceneID = Player.playlist.currentChapterNumber;

Player.generalParameters.setValue("sceneID", sceneID);

traceInfo(sceneID ,"sceneID");

}

Also, rather than setting this value everytime the user opens this menu, you can create an event listener for the chapter change event and set it only when it changes

addEventListener( "chapter", handleChapter ,false );

function handleChapter( evt )

{

Player.generalParameters.setValue("sceneID", evt.newValue);

}






Re: HD DVD Interactivity Authoring Scene Tracking

Eyeframe

Thanks all for your help, but i still can't get it to work. I've ammended the script now so it looks like this.....

function sceneTrackHandler()

{

var sceneID = Player.playlist.currentChapterNumber;

Player.generalParameters.setValue("sceneID", sceneID);

traceInfo(sceneID ,"sceneID");

}

function setScenesHandler(pageName)

{

var chapter = getData("sceneID");

switch(chapter)

{

case "0":

var id = "scene_13";

break;

case "1":

var id = "scene_23";

break;

case "2":

var id = "scene_33";

etc, etc, etc, etc

traceInfo(id ,"setting focus");

document.getElementById(id).state.focused = "true";

document.getElementById(id).state.unsetProperty("focused");

Player.generalParameters.setValue("sceneID", "initted");

All i'm doing from markup is adding another event when TOP_MENU is pressed

<event name="sceneTrack" />

with this in the script

application.addEventListener("sceneTrack", sceneTrackHandler, false );

I tried using your suggestion of

addEventListener( "chapter", handleChapter ,false );

function handleChapter( evt )

{

Player.generalParameters.setValue("sceneID", evt.newValue);

}

but i keep getting

: Invalid key value in GeneralParameters.setValue: error = -93000, message = "HDDVD_E_ARGUMENT"

am I not calling it from markup correctly





Re: HD DVD Interactivity Authoring Scene Tracking

Amy Dullard - MSFT

sorry, that should be Player.playlist.currentChapter.number

function sceneTrackHandler()

{

//old line

//var sceneID = Player.playlist.currentChapterNumber;

//new line

var sceneID = Player.playlist.currentChapter.number;

Player.generalParameters.setValue("sceneID", sceneID);

traceInfo(sceneID ,"sceneID");

}






Re: HD DVD Interactivity Authoring Scene Tracking

Clinic

This is just a guess, but I know the generalParameters.setValue requires string values. Maybe var sceneID is being captured as an integer, though this script is loosely typed... Maybe a string cast is in order.






Re: HD DVD Interactivity Authoring Scene Tracking

perquin

yes Player.playlist.currentChapter.number; return an integer.

Is your getData("chapID"); return a string if not your case need to be case 1: and not case"1":.

Philippe PERQUIN





Re: HD DVD Interactivity Authoring Scene Tracking

Eyeframe

Hi all. I've tried all the above but still not working. What do you mean by a string cast Is there another / better way of doing this than the way i'm trying to do it





Re: HD DVD Interactivity Authoring Scene Tracking

Eyeframe

Forgot to mention. When I use

Player.playlist.currentChapter.number; I get the Invalid key value error again.....

error = -93000, message = "HDDVD_E_ARGUMENT"





Re: HD DVD Interactivity Authoring Scene Tracking

Amy Dullard - MSFT

I suspsect something else is causing your error because I have tested both the following and they work without any exceptions being thrown. Try breaking your script down into smaller pieces wrapped in try-catch blocks to help isolate the issue. Also, run HDiSim with -jit in the command line so you can see what is happening with the script debugger.

addEventListener( "chapter", handleChapter ,false );

function handleChapter( evt )

{

Player.generalParameters.setValue("sceneID", evt.newValue);

}

function sceneTrackHandler()

{

var sceneID = Player.playlist.currentChapter.number;

Player.generalParameters.setValue("sceneID", sceneID);

}






Re: HD DVD Interactivity Authoring Scene Tracking

scott bates


Actually Amy, while HDiSim doesn't throw an exception, it should be. Cant say I've tested toshiba recently, but at least in the early days it didn't throw an exception in this case either. However Sonic's emulator does correctly throw the exception here.

the spec (unfortunately) very clearly states that both parameters in the setValue function must be strings. So while HDiSim has always let you store integers, floats, and booleans in a generalParameter, the only valid value from a spec perspective is a string, 255 chars max in length.

so the code in question should be written as:

function handleChapter( evt )

{

Player.generalParameters.setValue("sceneID", evt.newValue.toString());

}

function sceneTrackHandler()

{

var sceneID = Player.playlist.currentChapter.number;

Player.generalParameters.setValue("sceneID", sceneID.toString());

}



the trick then is to get it back out to the type you want it when you do a getValue... for example:

// I want an integer so use parseInt
gPreviousAudioTrack = parseInt( Player.generalParameters.getValue("11"), 10 );

//this one was a boolean going in
gSubtitleVisible = Player.generalParameters.getValue("3");
//so now I have to test the string and get it back to a boolean true/false
if (gSubtitleVisible === "false") {
gSubtitleVisible = false;
} else {
gSubtitleVisible = true;
}


hope that helps.

_scott




Re: HD DVD Interactivity Authoring Scene Tracking

Eyeframe

Hi Scott,

thanks so much. It was making me go a little bit insane. Works a treat now.

Cheers,

Phill