I must say I don't know a thing about scripting, though I managed to learn to decipher some portions. Still, I have a question: in marc2003's "Now Playing" panel is there any way to make it use artist pics stored in a folder on my hdd?
Here's the script:
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\marc2003\v2\common.js"
// ==/PREPROCESSOR==
var title_tf = fb.TitleFormat("%title%");
var album_tf = fb.TitleFormat("$if2(%album%,)");
var artist_tf = fb.TitleFormat("%artist%");
var g_font_title = gdi.Font("Agency FB", 34, 0);
var g_font_album = gdi.Font("Agency FB", 20, 0);
var g_font_artist = gdi.Font("Agency FB", 24, 0);
var album_img = null;
var artist_img = null;
var cycle = window.GetProperty("cycle", 200) - 200;
var limit = window.GetProperty("limit", 305) - 300;
var album_img_size = window.GetProperty("album_img_size", 490) - 400;
if(fb.IsPlaying) on_playback_new_track();
function on_playback_time(time) {
if(cycle > 0 && arr.length > 1 && (time % cycle == 0)) on_mouse_wheel(1);
}
function on_playback_stop(reason) {
if(album_img) album_img.Dispose();
if(artist_img) artist_img.Dispose();
g_metadb = album_img = artist_img = null;
if(reason != 2) window.Repaint();
}
function on_playback_new_track() {
g_metadb = fb.GetNowPlaying();
artist = artist_tf.EvalWithMetadb(g_metadb);
title = title_tf.EvalWithMetadb(g_metadb);
album = album_tf.EvalWithMetadb(g_metadb);
if(album_img) album_img.Dispose();
album_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
if(album_img) {
window.Repaint();
} else {
utils.GetAlbumArtAsync(window.ID, g_metadb, 0);
}
folder = data_folder + fb.TitleFormat("$crc32(%artist%)").EvalWithMetadb(g_metadb);
var jpg = utils.Glob(folder + "\\*.jpg").toArray();
var png = utils.Glob(folder + "\\*.png").toArray();
var gif = utils.Glob(folder + "\\*.gif").toArray();
arr = jpg.concat(png, gif);
index = Math.floor(Math.random()*arr.length)
load_image();
}
function on_mouse_wheel(delta) {
if(arr.length < 2) return;
index += delta;
if(index < 0) index = arr.length-1;
if(index == arr.length) index = 0;
load_image();
}
function load_image() {
if(artist_img) artist_img.Dispose();
artist_image_path = arr[index];
artist_img = gdi.Image(artist_image_path);
window.Repaint();
}
function on_mouse_lbtn_dblclk() {
try {WshShell.Run("\"" + artist_image_path + "\""); } catch(e) {}
}
function on_get_album_art_done(metadb, art_id, im, ip) {
album_img = im;
window.Repaint();
}
function on_size() {
ww = window.width;
wh = window.height;
}
function scale(gr, img, pos_x, pos_y, width, height, mth) {
var s = mth == "max" ? Math.max(width / img.width, height / img.height) : Math.min(width / img.width, height / img.height);
var nw = img.width * s;
var nh = img.height * s;
pos_x += ((width - nw) / 2);
pos_y += ((height - nh) / 2);
gr.DrawImage(img, pos_x, pos_y, nw, nh, 0, 0, img.width, img.height);
}
function on_paint(gr) {
if(artist_img) {
gr.FillSolidRect( 0, 0,ww, wh, RGBA(0,0,0,200));
scale(gr, artist_img, 0, 0, ww, wh, "min")
} else {
gr.FillSolidRect( 0, 0,ww, wh, RGB(240,240,240));
}
gr.FillSolidRect(20,wh-130,ww - 40,110,RGBA(90,90,90,175));
if(album_img) {
text_x = album_img_size + 25;
scale(gr, album_img, 10, wh-10-album_img_size, album_img_size, album_img_size, "min");
} else {
text_x = 30;
}
if(fb.IsPlaying) {
gr.GdiDrawText(title, g_font_title, RGB(255,255,255), text_x, wh-130, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(album, g_font_album, RGB(255,255,255), text_x, wh-80, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(artist, g_font_artist, RGB(255,255,255), text_x, wh-55, ww-text_x-40, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
}
}
function on_mouse_rbtn_up(x, y) {
var _menu = window.CreatePopupMenu();
var _cycle = window.CreatePopupMenu();
var _limit = window.CreatePopupMenu();
var _album = window.CreatePopupMenu();
var idx;
_cycle.AppendMenuItem(MF_STRING, 200, "Off");
_cycle.AppendMenuItem(MF_STRING, 205, "5 seconds");
_cycle.AppendMenuItem(MF_STRING, 210, "10 seconds");
_cycle.AppendMenuItem(MF_STRING, 220, "20 seconds");
_cycle.CheckMenuRadioItem(200, 220, window.GetProperty("cycle"));
_limit.AppendMenuItem(MF_STRING, 301, "1");
_limit.AppendMenuItem(MF_STRING, 303, "3");
_limit.AppendMenuItem(MF_STRING, 305, "5");
_limit.AppendMenuItem(MF_STRING, 310, "10");
_limit.CheckMenuRadioItem(301, 310, window.GetProperty("limit"));
_album.AppendMenuItem(MF_STRING, 490, "Small");
_album.AppendMenuItem(MF_STRING, 600, "Large");
_album.CheckMenuRadioItem(490, 600, window.GetProperty("album_img_size"));
_menu.AppendMenuItem(g_metadb ? MF_STRING : MF_GRAYED, 11, "Download artist art from Last.fm");
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _limit.ID, "Limit");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(artist_img? MF_STRING : MF_GRAYED, 12, "Open containing folder");
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _cycle.ID, "Cycle");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _album.ID, "Cover image size");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 99, "Properties");
_menu.AppendMenuItem(MF_STRING, 100, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 200:
case 205:
case 210:
case 220:
window.SetProperty("cycle", idx);
cycle = idx - 200;
break;
case 301:
case 303:
case 305:
case 310:
window.SetProperty("limit", idx);
limit = idx - 300;
break;
case 490:
case 600:
window.SetProperty("album_img_size", idx);
album_img_size = idx - 400;
window.Repaint();
break;
case 11:
WshShell.Run("\"" + script_path + "art.exe\" \"" + artist + "\" \"" + folder + "\" " + limit, 0, true);
on_playback_new_track();
break;
case 12:
WshShell.Run("explorer /select," + artist_image_path);
break;
case 99:
window.ShowProperties();
break;
case 100:
window.ShowConfigure();
break;
}
_menu.Dispose();
_cycle.Dispose();
_limit.Dispose();
_album.Dispose();
return true;
}
function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
Edit: and another one: using marc2003's "Playback Buttons", how would I go about adding other buttons (mainly 'media library search' and 'playback statistics/rate/5')? I need the "function(){fb.XXX()" bit.