hi guys. i'm in well over my head with this scripting malarkey and i'm really stuck. i've bodged togethe a script from other people's work that works almost perfectly. my only problem is a script error on startup if the playlist is empty (not a huge issue but i'd like to fix it)
i think this is the relvant part of the code....
var g_metadb = fb.GetFocusItem();
on_metadb_changed();
function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = window.GetProperty("Focused", 0) == 1 ? fb.GetFocusItem() : fb.GetNowPlaying();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}
function on_metadb_changed() {
//console error here when playlist is empty on startup
var wiki = fb.TitleFormat("http://en.wikipedia.org/wiki/$replace(%artist%, ,_)").EvalWithMetadb(g_metadb);
var myspace = fb.TitleFormat("http://www.myspace.com/$replace(%artist%, ,)").EvalWithMetadb(g_metadb);
var lastfm = fb.TitleFormat("http://www.last.fm/music/$replace(%artist%, ,+,/,'%'252F)/_/$replace(%title%, ,+,/,'%'252F)").EvalWithMetadb(g_metadb);
var youtube = fb.TitleFormat("http://www.youtube.com/results?search_query=$replace(%artist%+%title%, ,+,'(',,')',,/,+,&,and)").EvalWithMetadb(g_metadb);
Buttons = {
but1: new Button(0,0,bw,bh, {normal: images + "wiki.png", hover: images + "wiki_h.png"}, function(){WshShell.run(wiki);}, wiki),
but2: new Button(bw,0,bw,bh, {normal: images + "myspace.png", hover: images + "myspace_h.png"}, function(){WshShell.run(myspace);}, myspace),
but3: new Button(bw*2,0,bw,bh, {normal: images + "lastfm.png", hover: images + "lastfm_h.png"}, function(){WshShell.run(lastfm);}, lastfm),
but4: new Button(bw*3,0,bw,bh, {normal: images + "youtube.png", hover: images + "youtube_h.png"}, function(){WshShell.run(youtube);}, youtube)
};
}
obviously it's the first line that breaks it but i really think i need that line of code for when the playlist is populated. how can i work around this?