Log in

View Full Version : Random playback on Scenarist SD


srfscenar
1st June 2012, 13:35
Hi all,
I know I am getting us a little bit behind in time, but I would appreciate it if someone could help.

I have a main menu with only one button and 6 video tracks.
All I want to do is pressing that button in the menu and playback one of the video tracks randomly.
If I press it again to play another but not the same.

Can someone give me some directions?

Thanks!

srfscenar
1st June 2012, 17:58
Forgot to mention I use Scenarist...

rik1138
1st June 2012, 21:35
Random numbers are less than perfect in Scenarist (well, in DVD in general), but here's a solution:
The button jumps to a dummy PGC.
Pre commands on the PGC generate random #
(Do this by using the 'random' command on a range of something large, like several thousand. Then MOD the answer with 6, and add 1. I'm not in front of my Scenarist, but I can write out the exact commands if that doesn't make sense... This will give better results than just a random number from 1-6)

Then, you want to jump to the video that corresponds with your number.

So, you now have a random playback. But, you don't want to repeat any either, so you have to add another step:
If you aren't using many GPRMs in the project, set aside 6 of them for the 6 videos pieces. If they are 0, the video hasn't played. If they are 1, the video has played.

So, if you get a 2, check the GPRM for 2, if it's 1, then loop back to the Random generation and create a new number. If it's 0, store a 1 and jump to the video.
You also need some method to know if all 6 videos have been played, so you can clear the values and start over. You can simply count how many times video has played, once it's 6, clear everything.

Now, another problem might be that once you've played 4 or 5 videos, there's only 1 or 2 valid numbers left. It could take the player a while to randomly generate that remaining number. A way to avoid this:
Instead of re-drawing a random #, just increase it by 1 (don't exceed 6 though) and check to see if that video has played. This will result in the fastest playback of all 6 videos as you reach the end, but it does introduce a little predictability to the randomness of them (like if video 5 & 6 are the only 2 left, they will likely play in order since you are more likely to get a random number from 1-5 than the number 6).

With only 6 videos, this may not be a huge problem, but if you have 20 or something, and you've played 19 of them, the player could sit for a long time trying to randomly get that last number...

There's also some formulas you can use that utilize a prime-number counting scheme to play the videos in a seemingly random order, but that's probably overkill for 6 videos. If you have hundreds and you want them to be 'random' and never repeat, then you might want to use something like that, but I think for 6 the above solution is easiest.

Hopefully that all makes sense... :rolleyes: