Could someone help me get a script working? I've built a little menu that searches shoutcast based off of the genre of the playing track:
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\common.js"
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==
function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
gr.FillSolidRect(0,0,ww,wh,RGB(220,220,220));
}
//Split multiline tags into an array
function split_tag(t) {
var splitstrings = [", ",",","; "," - "," "];
var tag=fb.TitleFormat("$caps(%"+t+"%)").EvalWithMetadb(g_metadb);
//if (tag = "?") return;
var foo = -1;
do {
foo++;
var splitcheck = tag.indexOf(splitstrings[foo]);
}
while (splitcheck == -1 && foo < 6)
return tag.split(splitstrings[foo]);
}
//doesn't work
//Create a dynamic menu for a tag
function scast_menu(t,m,n) {
var tag = t;
var menu_index = m;
var menu_name = n;
fb.trace(tag.toString());
var times = tag.length;
var foo = -1;
do {
foo++;
_child4.AppendMenuItem(MF_STRING,foobar++,"Search for "+tag[foo]+" stations");
}
while (foo < times-1)
}
//Menu Commands
function on_mouse_lbtn_down(x, y) {
var basemenu = window.CreatePopupMenu();
var ret;
basemenu.AppendMenuItem(MF_STRING, 50, "Open a custom station...");
basemenu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var genres = split_tag("genre");
var times = genres.length;
var foo = -1;
var foobar=52;
do {
foo++;
basemenu.AppendMenuItem(MF_STRING,foobar++,"Search for "+genres[foo]+" stations");
}
while (foo < times-1)
basemenu.AppendMenuItem(MF_SEPARATOR, 0, 0);
basemenu.AppendMenuItem(MF_STRING, 51, "Most popular stations");
var ret = basemenu.TrackPopupMenu(x, y);
if (ret == 0)
return;
switch (ret)
{
case 50:
var scast_station = text_input_box("Shoutcast Radio","Search for a Shoutcast station","scast")
var shout = "http://www.shoutcast.com/radio/"+scast_station;
WshShell.Run(shout);
break;
case 51:
var shout = "http://www.shoutcast.com/most-popular-radio-stations";
WshShell.Run(shout);
break;
default:
var shout = "http://www.shoutcast.com/radio/"+encodeURIComponent(genres[ret - 52]);
WshShell.Run(shout);
break;
}
basemenu.Dispose();
}
Seems like the way to do it is would be to have on_metadb_changed() call window.Repaint(), and call the function that draws the menu in on_paint(gr), but hell if I can get it working.
Thanks if someone can help, I'll probably bumble my way to victory eventually but this is driving me up the wall.