Hmmm.... still not working after playing 4 songs for the same artist. My settings are:
Last.fm Options: Automatically Download (check)
Limit: 20
Blacklist Deleted Images (check)
Cycle: 20 seconds
Font Cover Display: Off
I have edited things in the script (from lines 7-16), but I don't think it should make a difference:
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common.js"
// @name "Now Playing"
// @author "marc2003"
// ==/PREPROCESSOR==
var stopped_text = "foobar2000";
var title_tf = fb.TitleFormat("[%discnumber%.]%tracknumber%'/'[%discnumber%.]%totaltracks% - %title%");
var album_tf = fb.TitleFormat("[%artist%]");
var artist_tf = fb.TitleFormat("$ifequal([%LASTFM_LOVED%],1,♥,)");
var title_font = gdi.Font("Segoe UI", 28, 1);
var album_font = gdi.Font("Segoe UI", 22, 1);
var artist_font = gdi.Font("Segoe UI", 22, 1);
var title_colour = RGB(40,179,255);
var album_colour = RGB(210, 210, 210);
var artist_colour = RGB(255,0,0);
var blacklist_file = '';
var title = '';
var artist = '';
var album = '';
var foobar_img = gdi.Image(images_path + "new foo.png");
var album_img = null;
var artist_img = null;
var arr = new Array();
var g_valid_tid = 0;
window.GetProperty("bl", true);
window.GetProperty("auto", true);
var cycle = window.GetProperty("cycle", 200) - 200;
var limit = window.GetProperty("limit", 305) - 300;
var album_img_size = window.GetProperty("album_img_size", 510) - 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) {
album_img && album_img.Dispose();
artist_img && artist_img.Dispose();
g_metadb = album_img = artist_img = arr = 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);
album_img && album_img.Dispose();
album_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
if(!album_img) utils.GetAlbumArtAsync(window.ID, g_metadb, 0);
folder = data_folder + fb.TitleFormat("$crc32(%artist%)").EvalWithMetadb(g_metadb);
bl();
arr = read_images();
if(arr.length == 0 && window.GetProperty("auto")) {
download_images();
} else {
index = Math.floor(Math.random()*arr.length);
load_image();
}
}
function on_mouse_wheel(delta) {
if(!g_metadb || arr.length < 2) return;
index += -delta;
if(index < 0) index = arr.length - 1;
if(index >= arr.length) index = 0;
load_image();
}
function load_image() {
artist_image_path = arr[index];
g_valid_tid = gdi.LoadImageAsync(window.ID, artist_image_path);
}
function on_load_image_done(tid, image) {
if (g_valid_tid == tid) {
artist_img && artist_img.Dispose();
artist_img = image;
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 on_paint(gr) {
gr.SetInterpolationMode(6);
if(artist_img) {
scale(gr, artist_img, 0, 0, ww, wh, "max");
} else {
gr.FillGradRect(0, 0, ww, wh, 90,g_backcolor, g_textcolor_hl);
}
gr.FillSolidRect(0,wh-130,ww,110,RGBA(0,0,0,156));
if(album_img && album_img_size > 0) {
text_x = album_img_size + 10;
scale(gr, album_img, 0, wh-20-album_img_size, album_img_size, album_img_size, "min");
} else {
text_x = 10;
}
if(fb.IsPlaying) {
gr.GdiDrawText(title, title_font, title_colour, text_x, wh -127, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(album, album_font, album_colour, text_x, wh - 80, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
gr.GdiDrawText(artist, artist_font, artist_colour, text_x, wh - 55, ww-text_x-10, wh,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
} else {
scale(gr, foobar_img, 0, 0, ww, wh - 130, "min");
gr.GdiDrawText(stopped_text, title_font, title_colour, 0, wh - 130, ww, 110,DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
}
}
function on_mouse_rbtn_up(x, y) {
var _album = window.CreatePopupMenu();
var _cycle = window.CreatePopupMenu();
var _menu = window.CreatePopupMenu();
var _lastfm_options = window.CreatePopupMenu();
var _limit = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(g_metadb ? MF_STRING : MF_GRAYED, 11, "Download artist art from Last.fm");
_lastfm_options.AppendMenuItem(MF_STRING, 1000, "Automatically download");
_lastfm_options.CheckMenuItem(1000, window.GetProperty("auto"));
_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.AppendMenuItem(MF_STRING, 320, "20");
_limit.CheckMenuRadioItem(301, 320, window.GetProperty("limit"));
_lastfm_options.AppendMenuItem(MF_STRING | MF_POPUP, _limit.ID, "Limit");
_lastfm_options.AppendMenuItem(MF_SEPARATOR, 0, 0);
_lastfm_options.AppendMenuItem(MF_STRING, 1001, "Blacklist deleted images");
_lastfm_options.CheckMenuItem(1001, window.GetProperty("bl"));
_lastfm_options.AppendMenuItem(fso.FileExists(blacklist_file) ? MF_STRING : MF_GRAYED, 1002, "Clear blacklist for this artist");
_lastfm_options.AppendMenuItem(MF_SEPARATOR, 0, 0);
_lastfm_options.AppendMenuItem(MF_STRING, 1003, "Explain blacklisting");
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _lastfm_options.ID, "Last.fm options");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_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"));
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _cycle.ID, "Cycle");
_album.AppendMenuItem(MF_STRING, 400, "Off");
_album.AppendMenuItem(MF_STRING, 510, "Small");
_album.AppendMenuItem(MF_STRING, 620, "Large");
_album.CheckMenuRadioItem(400, 620, window.GetProperty("album_img_size"));
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _album.ID, "Front cover display");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(artist_img ? MF_STRING : MF_GRAYED, 12, "Open containing folder");
if(artist_img) _menu.AppendMenuItem(MF_STRING, 15, "Delete this image");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
if(utils.IsKeyPressed(0x10)) _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:
case 320:
window.SetProperty("limit", idx);
limit = idx - 300;
break;
case 400:
case 510:
case 620:
window.SetProperty("album_img_size", idx);
album_img_size = idx - 400;
window.Repaint();
break;
case 11:
download_images();
break;
case 12:
WshShell.Run("explorer /select," + artist_image_path);
break;
case 15:
try {
if(window.GetProperty("bl") == true) {
ts = fso.OpenTextFile(blacklist_file, 2, true, -1);
ts.WriteLine(blacklist + arr[index] + "|");
ts.close();
}
artist_img.Dispose();
artist_img = null;
fso.DeleteFile(arr[index]);
} catch(e) {
fb.trace("Error: Could not delete " + arr[index]);
}
on_playback_new_track();
break;
case 99:
window.ShowProperties();
break;
case 100:
window.ShowConfigure();
break;
case 1000:
window.SetProperty("auto", !window.GetProperty("auto"));
break;
case 1001:
window.SetProperty("bl", !window.GetProperty("bl"));
break;
case 1002:
try { fso.DeleteFile(blacklist_file); } catch(e) {}
break;
case 1003:
fb.ShowPopupMessage("When you delete an image, there is no way for this script to prevent it being downloaded again. As a workaround, you can \"blacklist\" images you don't want and they will be deleted after downloading is complete.", "Now Playing");
break;
}
_lastfm_options.Dispose();
_menu.Dispose();
_cycle.Dispose();
_limit.Dispose();
_album.Dispose();
return true;
}