I´m trying to add more fields to the track info code, thanks Hitchhiker427 and Marc2003! and I kind a need a some help...
I´m using the line "playback = fb.TitleFormat("%playback_time%").EvalWithMetadb(g_metadb);" along with the gr.GdiDrawText one
to display the playback time but it always shows up "?".
Also how can I align the text to the left instead of using the "center of the word/field" so that I can align all the info such as playback time, bitrate, etc in the left like using a tab? Maybe replacing the "DT_CENTER" value?
Is it possible as well, to display the sample rate "in the natural behavior" like %filesize_natural% such that if it´s "48000 Hz" it displays "48 Khz" and what´s the syntax of the volume say in db to display it too? I couldn´t find it in the help files.
Here´s what I´m using:
var image_path = fb.FoobarPath + "colores personalizados\\";
var g_img = gdi.Image(image_path + "Fondo Azul.bmp");
var background_width = 220;
var background_height = 300;
var artist = title = album = track = '';
var bgcolor = RGB(238,246,253);
var textcolor1 = RGB(249, 249, 249);
var textcolor2 = RGB(249, 249, 249);
var font1 = gdi.Font("Segoe UI", 14, 1);
var font2 = gdi.Font("Segoe UI", 14, 1);
var font3 = gdi.Font("Segoe UI", 10, 0);
DT_CENTER = 0x00000001;
DT_NOPREFIX = 0x00000800;
DT_END_ELLIPSIS = 0x00008000;
g_metadb = fb.GetFocusItem();
on_item_focus_change();
function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}
function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.DrawImage(g_img, 0, 0, ww, wh, 0, 0, background_width, background_height);
if(g_metadb) {
gr.GdiDrawText(title, font1, textcolor1, 0, 0, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(artist, font2, textcolor2, 0, 17, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(album, font3, textcolor2, 0, 40, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(track, font3, textcolor2, 0, 50, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(channels, font3, textcolor2, 148, 3, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(playback, font3, textcolor2, 144, 16, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(bitrate, font3, textcolor2, 155, 29, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
gr.GdiDrawText(samplerate, font3, textcolor2, 155, 42, ww, 24, DT_CENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
}
}
function on_size() {
ww = window.Width;
wh = window.Height;
}
function on_metadb_changed() {
artist = fb.TitleFormat("$replace([%artist%],_, )$replace($stripprefix($substr([%title%],1,$sub($strstr(%title%,-),2)),-),_, )").EvalWithMetadb(g_metadb);
title = fb.TitleFormat("$replace($stripprefix($substr([%title%],$strstr(%title%,-),1000),-),_, )").EvalWithMetadb(g_metadb);
album = fb.TitleFormat("[%album%] ['('%date%')']").EvalWithMetadb(g_metadb);
track = fb.TitleFormat("[Track # %tracknumber%]").EvalWithMetadb(g_metadb);
playback = fb.TitleFormat("%playback_time%").EvalWithMetadb(g_metadb);
channels = fb.TitleFormat("%channels%").EvalWithMetadb(g_metadb);
bitrate = fb.TitleFormat("%bitrate% Kbps").EvalWithMetadb(g_metadb);
samplerate = fb.TitleFormat("%samplerate% Hz").EvalWithMetadb(g_metadb);
window.Repaint();
}
function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}
function on_playback_new_track() {
on_item_focus_change();
}
Thanks in advanced!
Edit: used the codebox instead.