Sample Auto-DJ script

From MediaMonkey Wiki
Jump to: navigation, search

This script demonstrates how to plug-in a script that manages how Auto-DJ works.

' Sample AutoDJ script
'
' This script demonstrates how to plug-in a script that manages how Auto-DJ works.
'
' [AutoDJSample]
' FileName=AutoDJSample.vbs
' DisplayName=AutoDJ Sample Plug-in
' Language=VBScript
' ScriptType=4
 
 
' This procedure is called when this script should show some UI on Options Panel (note that it's about a very small 
' panel to be shown, more details should be configured in a separate window)
' Panel = Panel where script can place its controls
Sub InitConfigSheet( Panel)
  ' TBD: Add some UI, mainly a button that would open another dialog with more controls for setting parameters of this AutoDJ.
End Sub
 
 
' This procedure is called when this script should remove its UI from Options Panel.
' Panel = Panel where UI controls were previously placed by the script
' SaveConfig = Whether user pressed Ok and values in the dialog should be applied and saved (to registry, ini file, or so)
Sub CloseConfigSheet( Panel, SaveConfig)
  ' TBD: Save values to Registry, apply them to our internal variables.
End Sub
 
 
' This function prepares a new track to be added to Now Playing queue
Function GenerateNewTrack
  ' This example only takes a random track from DB
  Set Iter = SDB.Database.OpenSQL( "SELECT ID FROM Songs ORDER BY random(*)")
  ID = Iter.ValueByIndex(0)
  Set Iter = SDB.Database.QuerySongs( "ID=" & ID)
  Set GenerateNewTrack = Iter.Item
End Function