Ok heres how i do it in Now Playing
players filenames are formatted as
classname.player.js
so lets say theres a file called "winamp.player.js"
and inside it there is
code:
var winamp = function(){
}
winamp.prototype = {
"helloWorld" : function(){
Debug.Trace('hello world');
}
}
and then we run this code, which loads all files in the /players directory and stores them into the plugins object
code:
var x;
var plugins = {};
var loadedPlugins = [];
for(var enume = new Enumerator(fso.GetFolder(MsgPlus.ScriptFilesPath + "\\players").Files);!enume.atEnd();enume.moveNext()){
if(x = new String(enume.item()).match(/([^[\\]*?)\.player\.js$/)){
loadedPlugins.push(x[1]);
try{
eval(fso.GetFile(enume.item()).OpenAsTextStream(1, 0).ReadAll());
plugins [x[1]] = eval(x[1]);
}catch{
Debug.Trace("ERROR loading player " + x[1] + ": \nType: " + e['name'] + "\nMessage: " + e['message'] + "\nNumber: " + x['number'] + "\nDescription: " + x['description']);
}
}
}
and then we can just use
code:
plugins['winamp'].helloWorld();