Correct Timer Code?  
Author Message
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

I am having trouble getting the timer function to work. Everytime it is called on while in the player, it crashes the player. Is this formatted correctly

var cbfnAudio = function()
{
//Animate Menu Code would be here
myTitleTimer.enabled = false;
};
var myTitleTimer = application.createTimer("00:00:01",1,cbfnAudio);
myTitleTimer.enabled = true;



Audio and Video Development3  
 
 
Peter Torr - MSFT





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

If you only want the timer to fire once (which is what it looks like), it is better to add:

timer.autoReset = false;

before you enable it. Then it will fire once and go away and you won't need to set enabled to false in your handler

As to the crashing... is your myTitleTimer variable a global variable or a function-local variable There are issues if you use a local variable as a timer because it will go out of scope and may be garbage collected.

Also, I presume your cbfnAudio function is more complicated than what you have posted :-). If you have any unhandled exceptions in that function, the player will stop. You should ensure all parts of the function are covered by try-catch exception handlers and recover appropriately.



 
 
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Thanks for the help Peter. I will try the autoReset call on Monday when I am back in the office.

The variable is currently local. I will also move that to global to avoid any further issues.

The cbfnAudio function is more complicated, but that was tested and working before the timer function was added. That I am comfortable with.

Actually, I am also having a similar issue with sound effects. I've gotten it to the point where it will run the code in the player, but I hear nothing. I can hear it when it is previewed in Scenarist Advanced Content. It's a 16bit/44.1kHz 2-channel WAV file. I had thought it was not getting mapped to any specific channels for output, so I added:

Player.audio.effect.setMixing(255,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0);

When that is added, the previewer works but the player crashes in a similar fashion to the timer issue. Any light you can shed on that would also be appreciated.

Jeff


 
 
Peter Torr - MSFT





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

There is a concept in HD DVD of "total volume condition" that basically means you need to balance the audio from the main, sub, and effect streams. You can't have all three of them playing at full volume all the time... the mixer only goes up to 10 :-)

You will need to turn down the main / sub audio before playing effect audio.



 
 
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Thanks again Peter. I could have sworn that the spec said the values were between 0 and 255. I don't remember seeing 10 anywhere. Since I posted that question, I started experimenting with the setVolumes and setMixing functions. I figured that the volume levels of the different audios had to be controlled somehow. Looks like I was right but was never going to get it to work correctly using the levels I was in the setMixing function. I wish the spec was a bit more detailed in that area. We're using v1.0 from August 2005. Is there one newer that we should be getting

Also thank you for the help with the timer code. Moving it to a global variable cleared all the issues right up.


 
 
Peter Torr - MSFT





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Actually, "it only goes up to 10" was a joke reference to "This is Spinal Tap" -- sorry! :-)

I don't have the spec with me, so I don't know what the real numbers are... but just be careful that you don't max out all three audio channels.

Good news on the timer front, then,



 
 
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

The Spinal Tap reference went right over my head. I'm showing my young age .

I got it working the same day I wrote that replay. The range is 0-255 for both setVolumes and setMixing. Turns out the setMixing was causing the crashing due to the fact that I wasn't using it in conjunction with the setVolumes function. I will only make that mistake once. Now I've got the main, sub, and effect audios all working great together.

To get even more off the original subject, do you know if there is a problem rendering text on the Toshiba players. I have tried everything I can possibly think of to get the most basic text to display and it just won't. I am mainly asking because of subtitling. Since I can't get the text to work, I switched to graphics. It seems like it's going to be too bulky for it to be the correct way.

And again, thank for all the help.


 
 
Peter Torr - MSFT





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Can you start a new thread for that, since it's a completely different question Thanks

 
 
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Will do Peter.
 
 
dmaietta





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

I've run into this same problem with audio mixing that appears to have been solved on the board back in June - however, I am still having trouble and was wondering if Jeff or Peter could post a snippet of code or give some additional information regarding the proper use of setVolume and setMixing.

Thanks! :)

 
 
Jeff Williams





PostPosted: HD DVD Interactivity Authoring, Correct Timer Code? Top

Well, I can post what works for me. It's all done in the script side, not the markup side. Do you have the HD spec There is a fairly complicated formula in the Annexes somewhere that you will need to use in order to get the right values for setVolumes and setMixing. They can range from 0-255. Below is what I am currently using.

Use this to initialize the mixer:

Player.audio.main.setVolumes(248,248,248,248,248,248,248,248);
Player.audio.sub.setMixing(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
Player.audio.effect.setMixing(235,0,0,235,0,0,0,0,0,235,0,0,235,0,0,0);

Put this where you want to hear the effect; i.e. when a menu opens or highlight changes:

Player.audio.effect.play("file:///dvddisc/ADV_OBJ/menu.aca/select.wav", 1, function (){});