My original Post to add randomized MP3s would fail if you moved your Tables folder away from it's original install. Here's an Update that will work for all installations
Here's a function to add music to a table, you just need the directory name where the music is stored. No need to number songs or call them out in the script. Songs are played randomly. You can add new songs to the directory and they will be picked up automatically.
Once the table script is updated and the table started. A song can be started or can be switched to next song by clicking the Right Magna key. The music can be stopped by clicking the Let Magna key
Here's the script. Change the text in red to the name of the directory that has your mp3 files
Const myMusicFolder = THE PATH TO YOUR MUSIC FOLDER ' example: Const myMusicFolder ="c:\vPinball\VisualPinball\Music\MotorHead"
Sub MusicOn
Dim FileSystemObject, folder, r, ct, file
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set folder = FileSystemObject.GetFolder(myMusicFolder)
Randomize
r = INT(folder.Files.Count * Rnd + 1)
ct=1
For Each file in folder.Files 'get every file in myMusicFolder, for each one count it and see if the count matches the random number
if ct = r Then ' random file found
if (LCase(Right(file,4))) = ".mp3" Then ' can only play mp3 files
PlayMusic Mid(file, 1, 1000)
End If
End If
ct = ct + 1
Next
End Sub
Sub Table1_MusicDone
MusicOn
End Sub
The only other thing you need to do is add the commands to catch the right and left Magna Keys in the KeyDown function. Add the lines in red
Sub Table1_KeyDown(ByVal keycode) 'may not be called Table1
If keycode = RightMagnaSave Then MusicOn
If keycode = LeftMagnaSave Then EndMusic ' VP command to stop all music
MusicOn can also be put in the Table1_Init sub to start music when the table starts
Make sure you save your changed (File/Save)