'////////////////////////////////////'// Global Variable Declaration'here declare global variables'(variables which are accessible from all events)'type allowed : string, integer, floatsub AtomicDef GlobalVariablesstring G_MP3Folder;Int G_MP3Count;end AtomicDef'////////////////////////////////////'// CommonFunctionssub AtomicDef CommonFunctions 'here write your common functions '(functions which are accessible from all events)'this function browser the folder to build the list of MP3 fileFunction BrowseFolder(foldername) G_MP3Count=0 'init MP3 coutner Set fso = CreateObject("Scripting.FileSystemObject") ' check if the folder exists If fso.FolderExists(foldername) Then ' get folder instance Set fd = fso.GetFolder(foldername) 'clear the internal MP3 list (list #1) ClearStringList 1 'browse each file in the folder For Each fl In fd.Files 'check if the file is a MP3 If InStr(LCase(fl.Name),".mp3")>0 Then 'if it is a MP3 we add it to the MP3 List (list #2) AddToStringList 1,fl.Name G_MP3Count=G_MP3Count+1 'maintain MP3 count in the list End if Next End If Set fso= NothingEnd Function end AtomicDef '////////////////////////////////////'// PluginInitsub AtomicEvent PluginInit 'this procedure is called on it of AtomicFE end AtomicEvent'////////////////////////////////////'// PluginLoadConfigsub AtomicEvent PluginLoadConfig 'this procedure is called each time a config is loaded 'get the MP3 folder , here we get the Layout (Template) directoryG_MP3Folder=GetConfigProperty("TEMPLATEDIR")+"\"'init MP3 global counterG_MP3Count=0'browse folder and build the MP3 ListBrowseFolder G_MP3Folderend AtomicEvent'////////////////////////////////////'// PluginChangeListItemsub AtomicEvent PluginChangeListItem'this procedure is called each time selected item in the list changes end AtomicEvent'////////////////////////////////////'// PluginBackToAtomicsub AtomicEvent PluginBackToAtomic 'this procedure is called each time atomic get back active end AtomicEvent'////////////////////////////////////'// PluginExitsub AtomicEvent PluginExit 'this procedure is called each time atomic exits end AtomicEvent'////////////////////////////////////'// Plugin RunGamesub AtomicEvent PluginRunGame'this procedure is called just before running a gameend AtomicEvent'////////////////////////////////////'// PluginKeyPressedsub AtomicEvent PluginKeyPressed'this procedure is called when user press a key end AtomicEvent////////////////////////////////////'// PluginRendersub AtomicEvent PluginRender 'this procedure is called each time atomic display a frame 'we play randomly (shuffle mode) 'if there is some MP3 in the folder If G_MP3Count>0 Then 'get a random index in the MP3 List index=GetRandomNumber(0,GetStringListSize(1)) '-1 'test if a MP3 is currently playing bIsPlaying=Is_MP3Playing() If bIsPlaying=-1 Then 'if not, we play the new MP3 MP3=GetStringListValueAt(1,index) Play_MP3(G_MP3Folder+"\"+MP3) End If End if end AtomicEvent'////////////////////////////////////'// PluginThreadsub AtomicEvent PluginThread 'this procedure is called when StartThread is called from another event end AtomicEvent