Archive for November, 2009

Keycode Access to play clips

image of the keypad used in the sample project

image of the keypad used in the sample project

An interesting thread on the Apple Discussions recently talked about whether it is possible to use a menu screen with a number pad graphic so that users could type in a clip number to play a clip. In the thread, the requirement was for 550 clips, and the original poster referred to them as ‘tracks’. Clearly, you can only have 99 tracks, so you always put all of your material into a single track and use markers to set the start/end points between the clips. The only other constraint is that a track can only have 99 markers in DVDSP. With 550 clips you’d need 6 tracks, and to keep the number of markers lower, you’d put just 50 clips into each of the tracks you use.

So then came the scripting - how do you keep track of what the user typed, and send them to the relevant marker? It’s actually a lot easier than you might think, using the button values on the menu to determine the clip value. The harder part comes when you have to do the jumps to the clips. When you write a script you only have 128 commands at your disposal. With a jump statement that includes an ‘if’ clause, you’ll get through those very fast and need quite a few scripts for 550 clips. Additionally, the scripts would go through sequentially, making finding the right clip a chore, and probably creating quite a pause.

The answer is to create a script for each clip that has just a single jump statement to get to that clip. The genius part here is that you use a ‘Jump Indirect’ to get the right script and so massively reduce the time for the player to get from the selection script to the playback. Don’t forget that DVDSP has a pretty hefty abstraction layer and there are lots of ways to slow things down, so anything you can do to help reduce delays is going to be good.

The remainder of the job is to add menu calls and end jumps to the markers - in the sample project I just sent everything through a script that clears the GPRMs and goes back to the main menu. Additionally, I had to add some logic to deal with the user selecting clips that didn’t exist, and to allow them to use a leading zero in their number, for selecting clip numbers 1 through 9.

The sample project file is here. You’ll probably need to reconnect the images I used for the track when you open the project.