Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod script discussion/help (Read 1401110 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #600
Folks who can help me change the default seekbar script to look like on the pic ?




I'm having trouble adjusting "on_mouse_move" after I set the margins. Any idea ? The default script is this

Themed seekbar


http://pastebin.com/yJW2NUwX

change the variable "H_padding" to adjust the distance between the bar and the margins.

BTW, the function clamp can be altered by this
function clamp(x, l, h) {
    return Math.min(Math.max(x,l),h);
}

P.S. your "mint" tastes wonderful~
mad messy misanthropist morbid mused


WSH Panel Mod script discussion/help

Reply #602
I've finally finished my config with WSH panels. It was pretty fun to do. I based my code on marc2003's, so some credits go to you, Marc2003 for doing the samples. If not for those I wouldn't have known left from right.


Panels code


Please, could you give me very detailed explanation on how to install your package this with all the nice last.fm tabulations ?

WSH Panel Mod script discussion/help

Reply #603
I think you better create a new thread asking how to create tab in your specific user interface component (DUI or CUI), as it is unrelated to this thread. After you have create the tabs, all you need to do is to import my panels code. How to do that has been included in my pack to some details, if you still need help for that, you can ask here, then.

Lastly, the code inside my pack is old and has some problems with certain responses from last.fm. I have fixed these issues in my current code but I'm at work now, will update the pack later.

WSH Panel Mod script discussion/help

Reply #604
a lrc file  shows wrong when 01:00.00

please check it

song:download

lrc file:download

i'll check it asap (maybe a bug fixed yesterday for some kind of ts!!!), thanks for reporting, update to come with the fix

Error: WSH Panel Mod ({96603E1C-15B1-4657-BEB3-A2A5389CA2BF}): Microsoft JScript 运行时错误:
无效的过程调用或参数
Ln: 769, Col: 5
<source text only available in compile time>

Ln: 769 is
  var tpath = Array(lyrics_dir1.EvalWithMetadb(g_metadb), lyrics_dir2);
Code: [Select]
/*
====================================================================================================
=======
Lyriks 1.2 (build 20101023.1300) - a WSH lyrics module by Br3tt
- This WSH script get lyrics from TAG first then from local file in Music folder then in foobar2000\lyrics\ and finally

it displays them (scrolling+sync)
- It handles TXT and LRC format (sync handled), but not the LRC Enhanced format (translated to simple LRC format)
- exotics timestamps are now handled (like [9:99], [99:99.999], [9:99.999], [99:99:999] ...)
- filenames supported are : <%artist%> -<%title%>.lrc (or .txt)  AND <%artist%> - <%title%>.lrc (or .txt)
- Comments, Blank lines (no timestamp) and Info lines (ar:, ti, ...) are ignored.
- Manual Scrolling possible with the mousewheel (double click on the panel to re-center on the active line)
- Requirements :
  1) foobar2000
  2) WSH Panel Mod component
  3) this script!
  4) Optional: a lyrics grabber (i.e: Lyric Show Panel by hidding the panel, foo_lyricsDB, ...)
- Some settings are available by using the panel Properties (right click on WSH panel -> Properties)
- This script don't make any changes to your files and write nothing on your system, except the creation of the folder

foobar2000/lyrics if not found
====================================================================================================
=======
*/

// Text formatting function
// {{
function StringFormat() {
var h_align = 0, v_align = 0, trimming = 0, flags = 0;
switch (arguments.length)
{
// fall-thru
case 4:
flags = arguments[3];
case 3:
trimming = arguments[2];
case 2:
v_align = arguments[1];
case 1:
h_align = arguments[0];
break;
default:
return 0;
}
return ((h_align << 28) | (v_align << 24) | (trimming << 20) | flags);
}
StringAlignment = {
Near: 0,
Centre: 1,
Far: 2
};
var lt_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Near);
var ct_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Near);
var rt_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Near);
var lc_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Centre);
var cc_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Centre);
var rc_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Centre);
var lb_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Far);
var cb_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Far);
var rb_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Far);
// }}

// Use with GdiDrawText()
// {{
var DT_LEFT = 0x00000000;
var DT_RIGHT = 0x00000002;
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_END_ELLIPSIS = 0x00008000;
// }}

//{{
// IO Mode
var ForReading = 1;
var ForWriting = 2;
var ForAppending = 8;
//}}

//{{
// Paths
var lyrics_dir1 = fb.Titleformat("$replace($replace(%path%,%filename_ext%,),\,\\)");
var lyrics_dir2 =  fb.FoobarPath + "lyric\\";
//}}

//{{
// new objects
sentence = function () {
this.timer = 0;
this.text = "";
this.total_lines = 0;
this.ante_lines = 0;
}
//}}

function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}

// ================================================/ TF
var len = fb.Titleformat("%length%");
var elap = fb.TitleFormat("%playback_time%");
var remain = fb.TitleFormat("%playback_time_remaining%");
var len_seconds = fb.Titleformat("%length_seconds%");
var elap_seconds = fb.TitleFormat("%playback_time_seconds%");
var remain_seconds = fb.Titleformat("%playback_time_remaining_seconds%");
var artist = fb.Titleformat("$replace(%artist%,'/','_')");
var title = fb.Titleformat("%title%");
var lyrics = fb.TitleFormat("[$if2(%LYRICS%,$if2(%LYRIC%,$if2(%UNSYNCED LYRICS%,%UNSYNCED LYRIC%)))]");

// ================================================/ Declarations
var g_font = gdi.Font("calibri", 12, 2);
var g_playtimer;
var g_metadb;
var ww = 0, wh = 0;

var PLAYTIMER_VALUE = window.GetProperty("Timer value in ms [10;100]", 10);
var LINE_HEIGHT = window.GetProperty("Line height [20;30]", 24);
var TEXT_SHADOW = window.GetProperty("Text shadow (true/false)", true);
var PLAIN_COLOR_BG = window.GetProperty("Plain colour background (true/false)", false);
var DITHER = window.GetProperty("Top & Botom dither (true/false)", true);
var H_PADDING = window.GetProperty("Horizontal padding [0;20]", 20);
var TXT_ALIGN = window.GetProperty("Text alignment (left/center/right)", "center");
var LIGHT_BG = window.GetProperty("Light background", true);
var DEBUG = false;
var DEFAULT_OFFSET = 29;

var g_fso = new ActiveXObject("Scripting.FileSystemObject");
var g_file = null;
var g_tab = Array();
var g_scroll=0;
var g_lyrics_path;
var g_lyrics_filename;
var g_lyrics_status;
var focus=0;
var focus_next=0;
var g_plainbg_colour;
var g_ovbg_normalcolour;
var g_ovbg_lineseparatorcolour;
var g_ovbg_highlightcolour;
var g_txt_normalcolour;
var g_txt_highlightcolour;
var g_txt_shadowcolour;
var centiemes = 0;
var g_is_scrolling = false;
var g_multi_balise = false;
var g_balise_total;
var g_balise_char_offset = 10;
var g_tab_length;
var g_txt_align;

var midpoint;
var pos;

// START
function on_size() {
var k;
ww = window.Width;
wh = window.Height;
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : false;
 
// exit test on useless calls made (wsh tweak)
if(!ww && !wh) return true;

midpoint = wh / 2 - LINE_HEIGHT / 2;

// colour definitions
// g_plainbg_colour = RGBA(140, 200, 250, 255);
// g_ovbg_normalcolour = RGBA(000, 000, 000, 255);
// g_ovbg_lineseparatorcolour = RGBA(000, 000, 000, 255);
// g_ovbg_highlightcolour = RGBA(020, 100, 240, 130);
// g_txt_normalcolour = RGBA(200, 200, 210, 255);
// g_txt_highlightcolour = RGBA(255, 255, 255, 255);
// g_txt_shadowcolour = RGBA(000, 000, 000, 150);


g_plainbg_colour = RGBA(140, 200, 250, 255);
g_ovbg_normalcolour = RGBA(255, 255, 255, 255);
g_ovbg_lineseparatorcolour = RGBA(255, 255, 255, 255);
g_ovbg_highlightcolour = RGBA(255, 255, 255, 255);
g_txt_normalcolour = RGBA(120, 120,120, 255);
// g_txt_highlightcolour = RGBA(148,148,239, 255);
g_txt_highlightcolour = RGBA(0,128,255, 255);
g_txt_shadowcolour = RGBA(255, 255, 255, 200);

g_playtimer && window.KillTimer(g_playtimer);

if(fb.IsPlaying||fb.IsPaused) {
g_scroll=0;
g_is_scrolling = false;
get_lyrics();
change_focus();
k = g_tab[focus].ante_lines * LINE_HEIGHT;
if(g_lyrics_status>0) {
pos = midpoint - k;
g_playtimer = window.CreateTimerInterval(PLAYTIMER_VALUE);
} else {
delta = (g_tab[g_tab.length-1].ante_lines + g_tab[g_tab.length-1].total_lines);
pos = (wh / 2) - (delta * LINE_HEIGHT / 2);
}
}
}

function on_paint(gr) {
PLAIN_COLOR_BG && gr.FillSolidRect(0, 0, ww, wh, g_plainbg_colour);
if(fb.IsPlaying||fb.IsPaused) {
show_lyrics(gr, g_tab, pos);
DEBUG && gr.GdiDrawText(g_lyrics_status.toString(), g_font, g_normalcolour, 5, 5, ww, LINE_HEIGHT, DT_TOP |

DT_LEFT | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
}
DITHER && gr.FillGradRect(0, 0, ww, 11, 90, g_txt_shadowcolour, RGBA(0,0,0,0));
DITHER && gr.FillGradRect(0, wh-11, ww, 11, 270, g_txt_shadowcolour, RGBA(0,0,0,0));
DITHER && gr.FillGradRect(0, 0, ww, 1, 90, g_txt_shadowcolour, RGBA(0,0,0,0));
DITHER && gr.FillGradRect(0, wh-2, ww, 1, 90, RGBA(0,0,0,0), g_txt_shadowcolour);
}

function on_mouse_lbtn_dblclk(x, y, mask) {
on_size();
}

function on_mouse_leave() {
window.Repaint();
}

function on_playback_time(time) {
// at each new seconde, centiemes is reset to 0 (Increment on timer every 100ms)
centiemes = 0;
if(g_lyrics_status==0) {
if(elap_seconds.Eval()==3) {
on_size();
}
window.Repaint();
}
}

function on_playback_new_track(info) {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : false;
g_playtimer && window.KillTimer(g_playtimer);
pos=0;
g_scroll = 0;
g_is_scrolling = false;
get_lyrics();
change_focus();
if(g_lyrics_status>0) {
g_playtimer = window.CreateTimerInterval(PLAYTIMER_VALUE);
}
}

function on_playback_seek(time) {
var k;
if(g_lyrics_status>0) {
g_scroll = 0;
g_is_scrolling = false;
change_focus();
k = g_tab[focus].ante_lines * LINE_HEIGHT;
pos = midpoint - k;
window.Repaint();
}
}

function on_playback_stop(reason) {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : false;
g_playtimer && window.KillTimer(g_playtimer);
if(reason==0) {
// Stop
window.Repaint();
}
}

function on_mouse_wheel(delta) {
if(g_lyrics_status>0) {
if(delta>0) {
pos = (pos>=midpoint)?pos:pos + LINE_HEIGHT;
} else {
pos = (pos<=(wh/2 - g_tab_length*LINE_HEIGHT))?pos:pos - LINE_HEIGHT;
}
window.Repaint();
}
}

function on_timer(id) {
var t1 = elap_seconds.Eval() * 100 + centiemes;
var t2 = len_seconds.Eval() * 100;
var p1, p2;
if(t1>t2-100) {
g_playtimer && window.KillTimer(g_playtimer);
}
if(g_playtimer) {
if(g_playtimer.ID == id) {
if(!g_is_scrolling && t1>=g_tab[focus_next].timer) {
p1 = g_tab[focus].ante_lines*LINE_HEIGHT;
p2 = g_tab[focus_next].ante_lines*LINE_HEIGHT;
g_scroll = p2 - p1;
change_focus();
g_is_scrolling = true;
}
if (g_scroll>0) {
pos -= 1;
g_scroll -= 1;
window.Repaint();
} else {
g_is_scrolling = false;
}
centiemes = (centiemes>98)?0:(centiemes+1);
}
}
}

function show_lyrics(gr, tab, posy) {
var i, k, text_colour;
gr.SetTextRenderingHint(5);
// decoding text alignment (from Properties)
switch(TXT_ALIGN.toUpperCase()) {
case "LEFT":
g_txt_align = lc_stringformat;
break;
case "CENTER":
g_txt_align = cc_stringformat;
break;
case "RIGHT":
g_txt_align = rc_stringformat;
break;
default:
g_txt_align = cc_stringformat;
}
if(g_lyrics_status>0) {
if(posy>=0) {
LIGHT_BG && gr.FillSolidRect(0, Math.floor(posy - wh/2), ww, Math.floor(wh/2), g_ovbg_normalcolour);
}
} else {
LIGHT_BG && gr.FillSolidRect(0, 0, ww, wh, g_ovbg_normalcolour);
}
for(i=0;i<tab.length;i++) {
if(Math.round(posy)>=(LINE_HEIGHT*-4) && Math.round(posy)<wh) {
if(i==focus && g_lyrics_status==1) {
text_colour = g_txt_highlightcolour;
} else {
if(g_lyrics_status==0) {
text_colour = g_txt_highlightcolour;
} else {
text_colour = g_txt_normalcolour;
}
}
if(g_lyrics_status>0) {
if(!LIGHT_BG && i==focus && tab[i].text.length>1 && g_lyrics_status==1) {
gr.FillSolidRect(0, Math.floor(posy), ww, (tab[i].total_lines*LINE_HEIGHT), g_ovbg_highlightcolour);
} else {
LIGHT_BG && gr.FillSolidRect(0, Math.floor(posy), ww, (tab[i].total_lines*LINE_HEIGHT-1), (i==focus

&& tab[i].text.length>1 && g_lyrics_status==1)?g_ovbg_highlightcolour:g_ovbg_normalcolour);
LIGHT_BG && gr.FillSolidRect(0, Math.floor(posy+(tab[i].total_lines*LINE_HEIGHT-1)), ww, 1,

g_ovbg_lineseparatorcolour);
}
}
TEXT_SHADOW && gr.DrawString(tab[i].text, g_font, g_txt_shadowcolour, 1+H_PADDING, Math.floor(posy)-1, ww-

H_PADDING*2, (tab[i].total_lines*LINE_HEIGHT), g_txt_align);
TEXT_SHADOW && gr.DrawString(tab[i].text, g_font, g_txt_shadowcolour, 1+H_PADDING, Math.floor(posy), ww-

H_PADDING*2, (tab[i].total_lines*LINE_HEIGHT), g_txt_align);
gr.DrawString(tab[i].text, g_font, text_colour, 0+H_PADDING, Math.floor(posy)-1, ww-H_PADDING*2, (tab

[i].total_lines*LINE_HEIGHT), g_txt_align);
}
posy = Math.floor(posy+LINE_HEIGHT+((tab[i].total_lines-1)*LINE_HEIGHT));
}
if(g_lyrics_status>0 && posy<=wh) {
LIGHT_BG && gr.FillSolidRect(0, Math.floor(posy), ww, Math.floor(wh), g_ovbg_normalcolour);
}
}

function grab_timer(t_tab) {
var tminutes, tsecondes, tcentiemes;
var i, k, f_sentence, b, c, delta, repeat_text;
var tab = Array();
for(i=0;i<t_tab.length;i++) {
if(g_lyrics_status==1) {
// -----------
// sync lyrics
// -----------
if(IsTimestamped(t_tab[i])) {
b = 0;
while(t_tab[i].substring(b*10, b*10+1)=="[") {
b++;
}
c = b;
repeat_text = remove_enhanced_balises(t_tab[i].substring(c*10, t_tab[i].length));
if(repeat_text.length==0) repeat_text = repeat_text + " ";
for(b=0;b<c;b++) {
f_sentence = new sentence;
tminutes = t_tab[i].substring(1+(b*10), 3+(b*10));
tsecondes = t_tab[i].substring(4+(b*10), 6+(b*10));
tcentiemes = t_tab[i].substring(7+(b*10), 9+(b*10));
f_sentence.timer = Math.round(tminutes)*60*100 + Math.round(tsecondes)*100 + Math.round(tcentiemes)

- DEFAULT_OFFSET;
if(f_sentence.timer<0) f_sentence.timer=0;
f_sentence.text = repeat_text;
tab.push(f_sentence);
}
}
} else {
// -------------
// unsync lyrics
// -------------
if(IsTimestamped(t_tab[i])) {
// if sync line in unsync lyrics, i remove timestamps in this line
b = 0;
while(IsTimestamped(t_tab[i].substring(b*10, b*10+10))) {
b++;
}
t_tab[i] = t_tab[i].substring(b*10, t_tab[i].length);
}
f_sentence = new sentence;
f_sentence.timer = 0;
f_sentence.text = t_tab[i];
tab.push(f_sentence);
}
}
if(tab.length==0) {
g_lyrics_status = 0;
tab = load_track_info();
delta = (tab[tab.length-1].ante_lines + tab[tab.length-1].total_lines);
pos = (wh / 2) - (delta * LINE_HEIGHT / 2);
} else {
f_sentence = new sentence;
f_sentence.timer = 9999999;
f_sentence.text = "---";
tab.push(f_sentence);
}
CollectGarbage();
return calc_lines(sort_tab(tab));
}

function load_file(filePath, fileName) {
var i;
var t_tab = Array();
var str;
g_file = open_file(filePath, fileName, ForReading);
while(!g_file.AtEndOfStream) {
str = g_file.ReadLine();
// blank lines are ignored
if(str.length>0) t_tab.push(str);
}
close_file(g_file);
return grab_timer(check_lyrics_type(t_tab));
}

function check_lyrics_type(t_tab) {
var i;
var count = 0;
var ts_percent;
var tab = Array();
for(i=0;i<t_tab.length;i++) {
if(IsTimestamped(t_tab[i])) {
// format timestamps to default syntax : [99:99.99]
tab.push(ts_analyzer(t_tab[i]));
// count # of sync lines
count++;
} else {
if(t_tab[i].length>0) tab.push(t_tab[i]);
}
}
// calc percent of sync lines, if more than 50% of the total filled lines, it's sync lyrics, else, unsync lyrics!
ts_percent = Math.round(count/tab.length*100);
if(ts_percent>50) {
// sync lyrics
g_lyrics_status = 1;
} else {
// unsync lyrics
g_lyrics_status = 2;
}
return t_tab;
}

function parse_tag(tag, delimiter) {
var t_tab = Array();
var i, j;
j = 0;
for(i=0;i<tag.length;i++) {
if(i==tag.length-1 || tag.charCodeAt(i)==10 || (i>0 && (i<tag.length-5) && (tag.substring(i, i+1)==delimiter) &&

(tag.substring(i-1, i)!="]"))) {
if(i==tag.length-1) {
t_tab.push(tag.substring(j, i+1));
} else {
t_tab.push(tag.substring(j, i));
}
if(tag.charCodeAt(i)!=10) {
j = i;
} else {
j = i+1;
}
}
}
return grab_timer(check_lyrics_type(t_tab));
}

function load_track_info() {
var tab = Array(new sentence, new sentence, new sentence, new sentence);
var count = 0;
tab[count].text = "---";
count++;
tab[count].text = artist.Eval();
count++;
tab[count].text = title.Eval();
count++;
tab[count].text = "---";
count++;
return calc_lines(tab);
}

function open_file(filePath, fileName, ioMode) {
var fileInst = null;
var bool = file_exists(filePath + fileName);
if(bool) {
fileInst = g_fso.OpenTextFile(filePath + fileName, ioMode);
}
return fileInst;
}

function close_file(fileInst) {
fileInst.Close();
}

function read_file(fileInst) {
var line = fileInst.ReadLine();
return line;
}

function folder_exists(folderPath) {
var fso, bool;
fso = new ActiveXObject("Scripting.FileSystemObject");
bool = fso.FolderExists(folderPath);
return bool;
}

function file_exists(filePath) {
var fso, bool;
fso = new ActiveXObject("Scripting.FileSystemObject");
bool = fso.Fileexists(filePath);
return bool;
}

function lyrics_folder_exists(folder_name) {
var fso;
var bool=1;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (folder_exists(fb.ProfilePath + folder_name) == false) {
fso.CreateFolder(fb.ProfilePath + folder_name);
bool=0;
}
return bool;
}

function change_focus() {
var i, j;
var t1 = elap_seconds.Eval()*100+centiemes;
if(g_lyrics_status>0) {
// search line index just after actual timer
for(i=0;i<g_tab.length;i++) {
if(g_tab[i].timer>t1) break;
}
focus_next=i;
focus = (i>0)?i-1:0;
// now i check if there are more than one line with the same timer as focus one & if found, i take it as new

focus 'cause it's the first (not a blank line)
if(focus>0) {
for(i=0;i<focus;i++) {
if(g_tab[i].timer==focus) {
focus = i;
break;
}
}
}
}
}

function calc_lines(ctab) {
var i, j;
var padx = 0;
var tmp_img;
var gp;
var lineh;
g_tab_length = 0;
if(ww==0) return ctab; // test to avoid errors if panel is hidden (ww=0)
tmp_img = gdi.CreateImage(ww-(H_PADDING*2)-padx, 100);
gp = tmp_img.GetGraphics();
for(i=0;i<ctab.length;i++) {
// calc sentence #lines to display / window.width
lineh = gp.MeasureString(ctab[i].text, g_font, 0, 0, ww-(H_PADDING*2)-padx, wh).Height;
ctab[i].total_lines = (lineh/LINE_HEIGHT) > Math.floor(lineh/LINE_HEIGHT) ? Math.floor(lineh/LINE_HEIGHT) + 1 :

Math.floor(lineh/LINE_HEIGHT) ;
ctab[i].ante_lines = 0;
for(j=0;j<i;j++) {
ctab[i].ante_lines += ctab[j].total_lines;
}
g_tab_length += ctab[i].total_lines;
}
CollectGarbage();
return ctab;
}

function sort_tab(tab2sort) {
var tab = Array();
var i, j;
var tmp = new sentence;
var smallest = 0;
for(i=0;i<tab2sort.length;i++) {
for(j=i;j<tab2sort.length;j++) {
if(tab2sort[i].timer > tab2sort[j].timer) {
tmp = tab2sort[i];
tab2sort[i] = tab2sort[j];
tab2sort[j] = tmp;
}
}
tab.push(tab2sort[i]);
}
return tab;
}

function remove_enhanced_balises(str) {
var i;
var chr1, chr2;
var new_str="";
for(i=0;i<str.length;i++) {
chr1 = str.substring(i, i+1);
if(i+10<=str.length) chr2 = str.substring(i+9, i+10); else chr2=null;
if(chr1=="<" && chr2==">") {
i = i + 10 - 1;
} else {
new_str = new_str + chr1;
}
}
return new_str;
}

function ts_analyzer(str) {
var i, j, ch,  ts_len;
var str2 = "";
var state=0;
var deb = -1;
var fin = -1;
var sep1 = -1;
var sep2 = -1;
var suite=0;
for(i=0;i<str.length;i++) {
ch = str.substring(i, i+1);
switch(state) {
case 0:
if(ch=="[" && IsNumeric(str.substring(i+1, i+2))) {
state=1;
deb=i;
fin=-1;
}
break;
case 1:
if(deb>=0 && ch==":") {
state=2;
sep1=i;
}
if(i>deb+3) {
deb=-1;
fin=-1;
sep1=-1;
sep2=-1;
state=0;
}
break;
case 2:
if(sep1>=0 && (ch==":" || ch==".")) {
state=3;
sep2=i;
}
if(sep1>=0 && sep2==-1 && ch=="]") {
state=4;
fin=i;
}
if(i>sep1+3) {
deb=-1;
fin=-1;
sep1=-1;
sep2=-1;
state=0;
}
break;
case 3:
if(deb>=0 && ch=="]") {
state=4;
if(i==str.length-1) {
str=str+" ";
}
fin=i;
}
if(i>deb+10) {
deb=-1;
fin=-1;
sep1=-1;
sep2=-1;
state=0;
}
break;
case 4:
ts_len=fin-deb+1;
switch(ts_len) {
case 6:
str2 = str2 + "[0" + str.substring(deb+1,deb+2) + ":" + str.substring(deb+3, deb+5) + ".00]";
break;
case 7:
str2 = str2 + str.substring(deb,deb+6) + ".00]";
break;
case 9:
str2 = str2 + "[0" + str.substring(deb+1,deb+2) + ":" + str.substring(deb+3, deb+5) + "." +

str.substring(deb+6, deb+8) + "]";
break;
case 10:
if(sep1==deb+2) {
str2 = str2 + "[0" + str.substring(deb+1,deb+2) + ":" + str.substring(deb+3, deb+5) + "." +

str.substring(deb+6, deb+8) + "]";
} else {
str2 = str2 + str.substring(deb,deb+10);
}
break;
case 11:
str2 = str2 + str.substring(deb,deb+9) + "]";
break;
}
j += 10;
if(str.substring(fin+1,fin+2)=="[") {
suite = 1;
i = fin;
deb = -1;
fin = -1;
sep1 = -1;
sep2 = -1;
state = 0;
} else {
suite = -1;
i = str.length - 1;
str2 = str2 + str.substring(fin+1, str.length);
}
break;  
}
}
return str2;
}

function IsNumeric(str) {
var ValidChars = "0123456789.";
for (i = 0; i < str.length; i++) {
if (ValidChars.indexOf(str.charAt(i)) == -1) {
return false;
}
}
return true;
}

function IsTimestamped(str) {
var ValidChars = "[0123456789:.]";
var count = 0;
for (i = 0; i < (str.length>10?10:str.length); i++) {
if (ValidChars.indexOf(str.charAt(i)) >=0) {
count++;
}
}
if(count>=6 && count <=11) {
return true;
} else {
return false;
}
}

function check_file(path, filename) {
if(file_exists(path+filename+".lrc")) {
g_lyrics_filename  = filename+".lrc";
g_lyrics_path = path;
return true;
} else {
if(file_exists(path+filename+".txt")) {
g_lyrics_filename  = filename+".txt";
g_lyrics_path = path;
return true;
}
}
return false;
}

function get_lyrics() {
var i, count, delta, tag;
var tpath = Array(lyrics_dir1.EvalWithMetadb(g_metadb), lyrics_dir2);
var tfilename= Array(artist.Eval() + " -" + title.Eval(), artist.Eval() + " - " + title.Eval());
var bool_tag = false;
var bool_file = false;
 
// reset lyrics tab
g_lyrics_status = 0;
if(g_tab.length>0) g_tab.splice(0, g_tab.length);
pos = midpoint;
focus = 0;
window.Repaint();
 
// check TAGs
tag = lyrics.Eval();
if(tag.length>0) {
bool_tag = true;
if(tag.substring(0,1)=="[") g_lyrics_status = 1; else g_lyrics_status = 2;
} else {
// check files
i = 0;
while(!bool_file && i<2) {
j = 0;
while(!bool_file && j<2) {
bool_file = check_file(tpath[i], tfilename[j]);
j++;
}
i++;
}
}
// if lyrics found
if(bool_tag || bool_file) {
if(bool_tag) {
g_tab = parse_tag(tag, "[");
} else {
g_tab = load_file(g_lyrics_path, g_lyrics_filename);
}
}  else {
g_tab = load_track_info();
delta = (g_tab[g_tab.length-1].ante_lines + g_tab[g_tab.length-1].total_lines);
pos = (wh / 2) - (delta * LINE_HEIGHT / 2);
}

if(g_lyrics_status==2) {
for(i=0;i<g_tab.length-1;i++) {
g_tab[i].timer = i * Math.floor(len_seconds.Eval() * 100 / g_tab.length);
}
}
}

WSH Panel Mod script discussion/help

Reply #605
the original tooltip button code is by T.P Wang and tedgo. i don't understand it that well either.

i'll try and work it out from what Tom posted.

in the meantime, i've updated my samples. they've all had their options updated to be accessible from the context menu only. no more script editing should be needed (one exception is setting the image size and margins for buttons).

http://cid-649d3bfeaf541fbb.skydrive.live....ide/samples.zip

samples include

rating script by NEMO7538
simple seekbar
simple biography
playback buttons
web links (myspace, youtube, lastfm)
3 in 1 artwork panel
-the first is a straight replacement for the default art panel. it always prefers embedded album art if it exists. it then falls back on the usual display options set in the foobar preferences.
-last.fm artist art panel. can download multiple images from last.fm and cycle through them. it must be triggered manually using the context menu
-cycle folder option. can cycle through images in a folder at 5, 10 or 20 second intervals

so no instructions needed really. just extract the scripts folder into your foobar directory. add panels and import the samples you want and right click them to see the various options.

EDIT: in the unlikely event someone downloaded this between 1:35-150pm today, please download it again. i didn't update the zip with my newest files. 


Hi guys,

Do you have any good idea to achieve the Album cover panel automatically download and mobile display cover?

BTW, I want to set Album text cache path to the location “D: \ Program Files \ Foobar2000V1.1 \ lastfm \ album“, but I hope it can instead using relative path for that never to worry about when folder and system changes. Could you hope me? I really appreciate you first.

WSH Panel Mod script discussion/help

Reply #606
marc, my foo_lastfm_radio along with your script WSH panel does not work, even with the the plugin configured with a username and password whenever I try to use the panel "similar artists" or "charts" of the same error: "Unable to launch last. fm radio ...."

I'm using the google translator, sorry but I am Brazilian

WSH Panel Mod script discussion/help

Reply #607
Hi guys,

Do you have any good idea to achieve the Album cover panel automatically download and mobile display cover?

BTW, I want to set Album text cache path to the location “D: \ Program Files \ Foobar2000V1.1 \ lastfm \ album“, but I hope it can instead using relative path for that never to worry about when folder and system changes. Could you hope me? I really appreciate you first.


for album covers, you'd be better off using foo_discogs or Album Art Downloader XUI

as for the path, if you install foobar in portable mode (preferably not in "program files"), then it already uses relative paths to a folder inside your foobar installation directory.

however, to fully customise it, you can open this file in your favourite text editor.....

Code: [Select]
foobar install dir\scripts\marc2003\v2\common.js


and scroll right to the bottom. look at line 351.....

Code: [Select]
var data_folder = fb.ProfilePath + "wsh_lastfm\\";


and change it as required. remember to use double backslashes when separating folders.

but as mentioned above, fb.ProfilePath already points to the foobar install dir when in portable mode. you could use fb.FoobarPath to point to the install directory regardless of mode but remember, windows doesn't usually allow write access to folders/files inside "program files".

"Unable to launch last. fm radio ...."


what happens if you try and use foo_lastfm radio normally either via "File>open last.fm radio" or use the "last.fm radio" context menu for any entry in your playlist.

it might be that last.fm doesn't allow streaming in your country.


WSH Panel Mod script discussion/help

Reply #609
what happens if you try and use foo_lastfm radio normally either via "File>open last.fm radio" or use the "last.fm radio" context menu for any entry in your playlist.

it might be that last.fm doesn't allow streaming in your country.


marc, I tried to use the File> Open Last.fm Radio Station> Your recommended Last.fm radio and it worked
is only in your script that does not work: (



WSH Panel Mod script discussion/help

Reply #612
Hi guys,

Do you have any good idea to achieve the Album cover panel automatically download and mobile display cover?

BTW, I want to set Album text cache path to the location “D: \ Program Files \ Foobar2000V1.1 \ lastfm \ album“, but I hope it can instead using relative path for that never to worry about when folder and system changes. Could you hope me? I really appreciate you first.


for album covers, you'd be better off using foo_discogs or Album Art Downloader XUI

as for the path, if you install foobar in portable mode (preferably not in "program files"), then it already uses relative paths to a folder inside your foobar installation directory.

however, to fully customise it, you can open this file in your favourite text editor.....

Code: [Select]
foobar install dir\scripts\marc2003\v2\common.js


and scroll right to the bottom. look at line 351.....

Code: [Select]
var data_folder = fb.ProfilePath + "wsh_lastfm\\";


and change it as required. remember to use double backslashes when separating folders.

but as mentioned above, fb.ProfilePath already points to the foobar install dir when in portable mode. you could use fb.FoobarPath to point to the install directory regardless of mode but remember, windows doesn't usually allow write access to folders/files inside "program files".

"Unable to launch last. fm radio ...."


what happens if you try and use foo_lastfm radio normally either via "File>open last.fm radio" or use the "last.fm radio" context menu for any entry in your playlist.

it might be that last.fm doesn't allow streaming in your country.


thanks for your reply, maybe your solution can help me, I will try some test.

WSH Panel Mod script discussion/help

Reply #613
Lyriks 1.3 released (bugs fix + tweaks)

Thanks

Curious, was this redundant:
Code: [Select]
// exit test on useless calls made (wsh tweak)
if(!ww && !wh) return true;


And please consider user defined color properties - every time I use new script I have to search this values inside script and make various adjustments by hand. What I'm saying is consider all "color definitions" in Properties
+ you changed the names of variables
Maybe also vertical height for gradient, which I always change to 32px, but it's easy to change parameter if it's only one

WSH Panel Mod script discussion/help

Reply #614
Timestamped lyrics aren't reseted when using seek-bar (seek back)


WSH Panel Mod script discussion/help

Reply #616
Scripting Engine Initialization Failed ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}, CODE: 0x86664004)
Check the console for more information (Always caused by unexcepted script error).


and

Can not create File System Object (FSO), WSH Cover Panel can't work.

I use Windows 7 and I think windows script host is installed by default.
here what I got in console:

Error: WSH Panel Mod ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}): Erro em tempo de execução do Microsoft JScript:
O servidor de automação não pode criar objeto
Ln: 45, Col: 3
<source text only available in compile time>
WSH Panel Mod ({2ADCA884-84EB-4B29-9BCC-B9491ABFF805}): initialized in 16 ms
WSH Panel Mod ({2E67F0FF-131A-4E6C-8162-5D269CDC4B44}): initialized in 3 ms
WSH Panel Mod ({3560A5C6-455B-4269-A51D-4443144330A3}): initialized in 11 ms
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Parsing file "C:\Users\soe9113\AppData\Roaming\foobar2000\\skins\ZiX+\Scrollbar\scrollbar.js": Failed to load
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): initialized in 118 ms
Error: WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Erro em tempo de execução do Microsoft JScript:
'VPSize' não está definido
Ln: 58, Col: 1
<source text only available in compile time>
WSH Panel Mod ({EA62CC17-FE36-4B8C-987D-EE4FE2D9285E}): initialized in 12 ms
WSH Panel Mod ({05FC3C9F-9AE7-4B2A-85F6-EBC5C6FBF042}): initialized in 26 ms
WSH Panel Mod ({0E317A12-BFF2-49A2-9965-3574476E9C06}): initialized in 12 ms
WSH Panel Mod ({AEFF8777-7709-4F68-B487-A99A9510830A}): initialized in 9 ms
Startup time : 0:01.784568

how can I solve this problem? I remember Appdata had some problems in other applications like mIRC

thanks

WSH Panel Mod script discussion/help

Reply #617
Scripting Engine Initialization Failed ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}, CODE: 0x86664004)
Check the console for more information (Always caused by unexcepted script error).

...

thanks

Is the Safe mode option unticked for WSH Panel Mod in File/Preferences?

Timestamped lyrics aren't reseted when using seek-bar (seek back)


right, i've found this bug after posting v1.3, next version is fixed, i'll share it soon.

ok, here is a new build that fix 2 bugs (reset position after a seek backward was wrong + bad scrolling length for some sync lyrics when the timer was higher to 10 ms)
+ colours in Properties panel

Lyriks 1.3 (build 20101103.2140) : http://pastebin.com/eVfJ2Ss8

WSH Panel Mod script discussion/help

Reply #618
Works great now, except:

Can you tell me how to adjust transition interval between active lines in timestamped lyrics? I think it was changed between versions and now it is too jumpy for my taste
I browsed your code and couple of your comments but nothing obvious there

WSH Panel Mod script discussion/help

Reply #619
Scripting Engine Initialization Failed ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}, CODE: 0x86664004)
Check the console for more information (Always caused by unexcepted script error).


and

Can not create File System Object (FSO), WSH Cover Panel can't work.

I use Windows 7 and I think windows script host is installed by default.
here what I got in console:

Error: WSH Panel Mod ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}): Erro em tempo de execução do Microsoft JScript:
O servidor de automação não pode criar objeto
Ln: 45, Col: 3
<source text only available in compile time>
WSH Panel Mod ({2ADCA884-84EB-4B29-9BCC-B9491ABFF805}): initialized in 16 ms
WSH Panel Mod ({2E67F0FF-131A-4E6C-8162-5D269CDC4B44}): initialized in 3 ms
WSH Panel Mod ({3560A5C6-455B-4269-A51D-4443144330A3}): initialized in 11 ms
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Parsing file "C:\Users\soe9113\AppData\Roaming\foobar2000\\skins\ZiX+\Scrollbar\scrollbar.js": Failed to load
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): initialized in 118 ms
Error: WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Erro em tempo de execução do Microsoft JScript:
'VPSize' não está definido
Ln: 58, Col: 1
<source text only available in compile time>
WSH Panel Mod ({EA62CC17-FE36-4B8C-987D-EE4FE2D9285E}): initialized in 12 ms
WSH Panel Mod ({05FC3C9F-9AE7-4B2A-85F6-EBC5C6FBF042}): initialized in 26 ms
WSH Panel Mod ({0E317A12-BFF2-49A2-9965-3574476E9C06}): initialized in 12 ms
WSH Panel Mod ({AEFF8777-7709-4F68-B487-A99A9510830A}): initialized in 9 ms
Startup time : 0:01.784568

how can I solve this problem? I remember Appdata had some problems in other applications like mIRC

thanks


A ZiX+ user, right?

well, when i was compiling the codes of scrollable trackinfo panel, it never occurred to me that many people choose to use the standard installation and i used the profile path in predecessor:(

BTW, please uncheck the safe mode in WSH panel.

I will fix this problem asap.
focus on my deviantart page.
mad messy misanthropist morbid mused

WSH Panel Mod script discussion/help

Reply #620
Works great now, except:

Can you tell me how to adjust transition interval between active lines in timestamped lyrics? I think it was changed between versions and now it is too jumpy for my taste
I browsed your code and couple of your comments but nothing obvious there


now the timer should not be greater than 10 ms (if greater, it will cause bad scrolling offsets on certain sync lyrics!)

but you can change the scroll step value, actually set to 1 (max), change it for a lower value for a slower scrolling, like 0.5, it's line 39:


 

WSH Panel Mod script discussion/help

Reply #621
samples updated:

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip

i've updated the "simple biograhy" script to use the new redirection feature made available in the last.fm API. this helps if your files are incorrect tagged.

old version of script with wrong tags / new script with spelling correction off


new version of script, wrong tags, spelling correction on:


note this does not touch your file tagging at all. it's simply for display purposes.

WSH Panel Mod script discussion/help

Reply #622
I had one layout and it kept happening, I deleted it (manually though) and it keeps happening with a different layout (which wasn't written by me):



Sometimes it goes away when I  right-click on a panel and press OK, but usually it doesn't and I have to restart a zillion times until it somehow, magically starts to work.

Safe Mode is disabled.


Scripting Engine Initialization Failed ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}, CODE: 0x86664004)
Check the console for more information (Always caused by unexcepted script error).


and

Can not create File System Object (FSO), WSH Cover Panel can't work.

I use Windows 7 and I think windows script host is installed by default.
here what I got in console:

Error: WSH Panel Mod ({EA64722C-DA97-4460-94BB-B6B5A2C5FF14}): Erro em tempo de execução do Microsoft JScript:
O servidor de automação não pode criar objeto
Ln: 45, Col: 3
<source text only available in compile time>
WSH Panel Mod ({2ADCA884-84EB-4B29-9BCC-B9491ABFF805}): initialized in 16 ms
WSH Panel Mod ({2E67F0FF-131A-4E6C-8162-5D269CDC4B44}): initialized in 3 ms
WSH Panel Mod ({3560A5C6-455B-4269-A51D-4443144330A3}): initialized in 11 ms
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Parsing file "C:\Users\soe9113\AppData\Roaming\foobar2000\\skins\ZiX+\Scrollbar\scrollbar.js": Failed to load
WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): initialized in 118 ms
Error: WSH Panel Mod ({5D5CBB4E-09F1-4BC3-9329-6B485FC21525}): Erro em tempo de execução do Microsoft JScript:
'VPSize' não está definido
Ln: 58, Col: 1
<source text only available in compile time>
WSH Panel Mod ({EA62CC17-FE36-4B8C-987D-EE4FE2D9285E}): initialized in 12 ms
WSH Panel Mod ({05FC3C9F-9AE7-4B2A-85F6-EBC5C6FBF042}): initialized in 26 ms
WSH Panel Mod ({0E317A12-BFF2-49A2-9965-3574476E9C06}): initialized in 12 ms
WSH Panel Mod ({AEFF8777-7709-4F68-B487-A99A9510830A}): initialized in 9 ms
Startup time : 0:01.784568

how can I solve this problem? I remember Appdata had some problems in other applications like mIRC

thanks


WSH Panel Mod script discussion/help

Reply #623
but you can change the scroll step value, actually set to 1 (max), change it for a lower value for a slower scrolling, like 0.5, it's line 39:

Thanks Falstaff
I've set it to 0.2
Now it's greater then ever

Cheers

WSH Panel Mod script discussion/help

Reply #624
thanks for all replies, I disabled safe mode and now is working ok. Thanks.
I like ZiX+ cause  is a very clean and easy skin. I tried others but some other skin got lot of problems, maybe components not updated.