|Page (2) of 2 - 06/09/05||email article||print page|
Conditional Chapter Jumps in DVD Studio ProScripting dynamic chapter playback and a 'play all' button Command 5: Set GPRM. Here's our last Set GPRM command for this script. We now need to add a specific value to the result we've currently attained in GPRM 2, and this value is 49280. The reason for this is that our track, being the first track in order in the Outline tab, has a value of 49280. That's just the way it works. Then, each chapter in this track has a numerical value 1 higher than 49280. So Track 1, Chapter 1 has a value of 49280; Track 1, Chapter 2 has a numerical value of 49281; Track 1, Chapter 3 has a numerical value of 49282; et cetera. Get the idea? We're placing a numerical value in GPRM 2 that's the reference number for a particular chapter, derived dynamically by the number of the button we've pressed, then dividing, subtracting and adding certain values to get to the actual chapter jump.
For this one, set the Operation to "Add," the Source Type to "Immediate," the Source Value to "49280" and the Target to "GPRM 2."
Incidentally, if you are using more than one track in your project, you will want to create additional scripts to handle the chapters for those tracks, although it is possible to economize everything down to a single script. (It's beyond the scope of this article to do so here, but I could write up a follow-up article if there are many of you who wish to do this.) To refer to any track, you simply take the base value of 49280 and add 128 to it for each subsequent track. Track 2, for example, would be 49408 (with each chapter adding 1 to that value). Track 3 would be 49536. Track 4 would be 49664. (You begin to see why there's a limit on the total number of tracks in a project.)
Command 6: Jump Indirect. Now, finally, we put in the command that will actually jump us to the proper chapter. For this one, we're going to take the value currently stored in GPRM 2 and tell the player to jump to the element of our DVD to which that number refers--in this case, a particular chapter. To do this, create a new command, and set it to "Jump Indirect." And set the "Set To" value to "GPRM 2."
Now connect this script to each one of you're chapter buttons, and by pressing any one of those buttons, you'll be redirected automatically tot he appropriate chapter. "One Script Fits All." Not bad.
Script 3: Chapter end jumps
Now, all of this, of course, was setting us up for the ultimate goal of this project, which is to allow the viewer to play individual chapters, then have each chapter, when it ends, jump back tot he chapter index menu (or some other menu). At the same time, we want to be able to use the same track to play the entire presentation all the way through, so we can't simply set the end jump of each chapter back to a menu, or we wouldn't be able to play the track all the way through. Therefore we'll set the end jump of each chapter to a script, which will then determine whether to play on or go back to a menu when the track has finished. (Again, it's easier to do this with Stories in most cases, but we'll do it this way because there are times when scripting will work out better for you. Plus, hey, you get to learn a bit about scripting, and you never know when this kind of information will come in handy for a future project, even if you don't use it for this particular purpose.)
For this process, we need to use four commands. So create a new script in your project, and rename it "Chapter Forward." This script will be used as the end jump for each of the chapters in the track.
Command 1: Jump. The first command will determine whether the chapter should jump back to a menu or keep playing. So make it a Jump command. Set the Jump To value to "Menu X" (whichever menu you want the chapter to jump to). Then check the checkbox at the bottom of the Script Inspector. We want top jump back to a menu right now only if the user has viewed this chapter via one of the direct chapter selection buttons. And when the user clicked one of those buttons, you'll recall, he or she activated a script that set the value of GPRM 0 to "1." Therefore, for this comparison, we want to Jump to a menu only if GPRM 0 is currently set to 1. So the comparison would read Execute if GPRM 0 is = to Immediate with value 1. (See screen shot below.)
Command 2: Set GPRM. Now, if that condition hasn't been met, we can't just tell the DVD to move on to the next chapter. We have to do it in a roundabout way. The first step in this process is to set a base value (the numerical value of the track). So add the Set GPRM command, and set the Operation to "mov," the Source Type to "Special," the Source Value to "Last Item" (the track, in this case) and the Target to "GPRM 1."
But we only want to set this source value once, no matter how many chapters we have. Therefore, we'll add in a conditional statement by checking the Compare Command checkbox. It will read Execute if GPRM 1 is < (less than) to Immediate with value 49280.
Command 3: Set GPRM. Now we need to add 1 to the value stored in GPRM 1 in order to advance to the next chapter, whichever chapter that happens to be. So we add another Set GPRM command. This time, set the Operation to "add," the Source Type to "Immediate," the Source Value to "1" and the Target to "GPRM 1."
In this way, when the track starts playing, the value will be set to 49280, then increased by one for each chapter that's played subsequently.
Command 4: Jump Indirect. And, finally, we tell the script to jump to the element of our DVD that has a numerical value equivalent to the value stored in GPRM 1. So set the command to Jump Indirect, and set the Set To value to "GPRM 1."
Putting it all together
Finally, all you need to do is connect these scripts tot heir respective elements, plus set the final end jump of your main track. Open up Menu 1, and connect the Play All script to the button that will be used for the Play All functionality. You can do this in the Menu Editor window simply by dragging the script onto the Play All button you've created.
For the Play Chapter script, connect this to each of your chapter selection buttons. You can do this simply by dragging the script repeatedly from the Outline tab to the individual buttons in your chapter index menu.
For the Chapter Forward script, this needs to be connected by selecting the chapter marker in the Track Editor window, then connecting the End Jump setting to the script in the Inspector palette. You must do this for each of the chapter markers individually.
Finally, for the final end jump of the track, click on the track in the Outline tab, then, in the Inspector palette, set the End jump to the menu or element of your choice.
That is all there is to it. Once again, you can download my project by clicking on the following link.
Download: DVDSP_Dynamic_Chapters.zip (80 KB)
If you're looking for more information on scripting in DVD Studio pro, please visit one of the following links.
DVD Studio Pro Scripting, Series 1
- Part 1: General scripting information
- Part 2: Creating an interactive quiz
- Part 3: Keeping track of time
- Part 4: Pausing and resuming a timer
- Scripting dynamic chapter selections
- Scripting system streams, Part 3 (audio switching)
- Scripting system streams, Part 2 (audio menu)
- Scripting a dynamic 'play all' button
- Scripting system streams, Part 1 (subtitles)
- Scripting previous/next buttons for menu navigation
- DVDSP General Walkthrough
- Customizing Button States
- Highlights and Overlays
- Zoom Masks
- Customizing Masks
- Fixing color shift (for DVDSP 2.0)
- Motion Masks (custom patches)
- Remote Rollovers
- Setting Up DTS Playback on the Mac
- Creating Alpha Transitions, Part 1
- Quick Tip on Stories
- Alpha Transitions, Part 2
- Delaying Button Highlights
- Buttons over Video
- Media Storage
- Creating a "Play All" Button by Merging Tracks
- Display Conditions and Prescripts
- Bitrates in DVD Studio Pro
And, if you have any other questions (or would like me to expand on any point in this tutorial), be sure to visit me in our DVD Studio Pro forum by clicking here.
Related Keywords:apple dvd studio pro, dvdsp, dvd studio pro 4, scripting, free scripting tutorial, chapter selection, end jumps, chapter markers
To Comment on This Article, Click HERE
Most Recent Reader Comments:
Click Here To Read All Posts
Must be Registered to Respond (Free Registration!!!, CLICK HERE)
Source:Digital Media Online. All Rights Reserved