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 1376103 times) previous topic - next topic
BadWolf and 2 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #125
I think i got it:
Code: [Select]
var ext_lyrics = window.GetProperty("Lyrics Path", "$directory_path(%path%)\\%artist% - %title%");

var arr = utils.Glob(fb.TitleFormat(ext_lyrics).Eval() + ".*").toArray();
for (var i = 0; i < arr.length; ++i) {
    if (arr[i].match(/\.lrc$/m)) d = utils.ReadTextFile(arr[i]);
    else if (arr[i].match(/\.txt$/m)) d = utils.ReadTextFile(arr[i]);
}

Seems to work at least...
It excludes all files beside lrc and txt.
But it prefers txt files over lrc, although i ask for lrc first.
Any idea how to solve this?
(Or did i made again an error?)

I want to prefer lrc because it is always a lyrics file, but txt may contain something else than lyrics...

WSH Panel Mod script discussion/help

Reply #126
you'll want to break the loop when the first file is found. your problem is that the last file in the array is used.

as the filenames are the same, this should be safe to do because .lrc comes before .txt alphebetically.

WSH Panel Mod script discussion/help

Reply #127
And how can i solve it? Any idea?

WSH Panel Mod script discussion/help

Reply #128
just thinking about it, it's a bit presumptuous of me to assume the files will be in the array in alphabetical order. let's hope so.

to break out of a loop....

break;

(or increase i beyond the maximum boundary)

edit: just had another thought. i'd never really noticed that utils.ReadTextFile function before. wouldn't it be easier just to try and load the files with that? as you only have 2 possibilities, it saves messing about with all this array nonsense.

WSH Panel Mod script discussion/help

Reply #129
I don't think that break would help here.
I guess the problem is utils.ReadTextFile(arr).
It seems that this arr will always match the last one in alphabetical order...
(Renamed lrc to xxx and tried it again. now it is loaded no matter if i ask for it first or last...)

EDIT (to your edit):
Is one other solution, yes.
But i wanted a more elegant way
Should work, though (why i haven't had this idea by myself? Grrr... )

WSH Panel Mod script discussion/help

Reply #130
I don't think that break would help here.


2nd edit...    (sorry for the misinformation before)

Code: [Select]
loop:
for (var i = 0; i < arr.length; ++i) {
    if (arr[i].match(/\.lrc$/m)) {
        d = utils.ReadTextFile(arr[i]);
        break loop;
    } else if (arr[i].match(/\.txt$/m)) {
        d = utils.ReadTextFile(arr[i]);
        break loop;
    }
}


3rd edit: my original post using 2 arrays and concat would have preferred lrc files but you went with T.Ps code...

this is getting very messy. 

WSH Panel Mod script discussion/help

Reply #131
3rd edit: my original post using 2 arrays and concat would have preferred lrc files but you went with T.Ps code...


Looked more logical.
I'll see what i do now...

EDIT:
You break loop doesn't change anything.
utils.ReadTextFile(arr) still prefers the last file in an alphabetical row.
How the hell could i make this to LRC?
Or i advice all the possible users of my script to delete all their lrc's, would be the easiest to code 

WSH Panel Mod script discussion/help

Reply #132
You break loop doesn't change anything.


works for me. try fb.trace to see if they are in order like mine....

Code: [Select]
arr = new Array("a.lrc", "a.txt");
fb.trace(arr[0]);
fb.trace(arr[1]);
loop:
for(var i = 0; i < arr.length; i++) {
    if (arr[i].match(/\.lrc$/m)) {
        d = arr[i];
        break loop;
    } else if (arr[i].match(/\.txt$/m)) {
        d = arr[i];
        break loop;
    }
}
fb.trace(d);

//console output
a.lrc
a.txt
a.lrc

//confirmed by removing break statement
a.lrc
a.txt
a.txt

WSH Panel Mod script discussion/help

Reply #133
Guess what?
It is working now. Thanks
Maybe i made a typo before, but now it works.

Now i can finish my lyrics panel

WSH Panel Mod script discussion/help

Reply #134
I have taken marc2003's lastfm biography code and modified it to display lyrics stored within ID3 tags.
I liked the style of the lastfm code, so I created this to work around that.

link

WSH Panel Mod script discussion/help

Reply #135
Very short code
But why do you create a context menu with the default context menu entries only?
You could delete the whole on_mouse_rbtn_up() section.

Here is my current preliminary lyrics panel script:
http://pastebin.de/3533

Maybe someone finds it useful
If anybody has ideas to improve it, please let me know.

WSH Panel Mod script discussion/help

Reply #136
Guys any idea why
WshShell.run("http://www.last.fm/music/" + encodeURIComponent(artist).replace(/\s+/,"+"));
doesn't replace the space in the artist name with a + ?

WSH Panel Mod script discussion/help

Reply #137
try

Code: [Select]
"http://www.last.fm/music/" + artist.replace(/\s+/g,"+")


i only use encodeURIComponent for accessing the webservices.

WSH Panel Mod script discussion/help

Reply #138
just another update to my samples....

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

as my old pack contained 3 separate artwork panels, i've taken a big hammer and merged them all into one. it has 3 modes.

-default foobar artreader
-lastfm artist art with built in download facility (uses this command line tool made by paradog (runs silently - you won't notice it at all). you don't need to download it - i've included it. it's just 8kb in size. and the effort it's saved me is untrue. )
-cycle folder. you just set some title formatting and it will automatically cycle all the images. options are off, 5, 10 and 20 seconds.

(the last.fm mode supports this cycling as well.)

everything is controlled via context menu except the path for the "cycle folder". you need to edit the script itself to set that.


WSH Panel Mod script discussion/help

Reply #139
marc can you please take a shot at this?
Quote
Can some kind soul convert the playback section of this theme (buttons, progress, volume etc) to a script for someone like me who doesn't know even a little but of jscript
Thanks
http://fanco86.deviantart.com/art/MonoLite-122756120

WSH Panel Mod script discussion/help

Reply #140
the playback controls and background are panel stack splitter. the volume control, seekbar and playback order button are 3 separate WSH scripts. you can right click those, select configure to open the editor and then export the contents to a text file. or you can use the columns UI layout page to copy panels between layouts. i

WSH Panel Mod script discussion/help

Reply #141
edit: question removed. totally unrelated to the scripting. 

WSH Panel Mod script discussion/help

Reply #142
Hi i want to make a seek bar with WSH panel mod but i dont know nothing about script's.Any help? Here is a pic of my Foobar
Thanks in advance.



By wizard20 at 2010-01-30

WSH Panel Mod script discussion/help

Reply #143
here is what i use:

SEEKBAR

Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

var g_font = gdi.Font("Segoe UI", 12, 0);
var g_drag = 0;

function on_paint(gr){
    gr.SetTextRenderingHint(5);
    var ww = window.Width;
    var wh = window.Height;
    var pos = 0;
    var length = fb.PlaybackLength;
    

    
    if (length>0){
        if(g_drag){
            pos = ww * g_drag_seek;
        } else {
            pos = ww * (fb.PlaybackTime / length);
        }
    }

       var txt = "Seekbar";
       gr.DrawRect(0,0,ww-1,wh-1,1.0,RGB(0,0,0));
       gr.FillSolidRect(1,1,ww-2,wh-2,RGB(28,28,28));
      
    var dio1 = 0.375*(wh-2);
       var dio2 = 0.625*(wh-2);

       gr.FillSolidRect(1,1,pos-1,dio1,RGB(119,187,255));
       gr.FillSolidRect(1,1+dio1,pos-1,dio2,RGB(51,153,255));

}
function on_mouse_lbtn_down(x,y){
    g_drag = 1;
}
function on_mouse_lbtn_up(x,y){
//    on_mouse_move(x,y);
    g_drag = 0;
    g_drag_seek = x / window.Width;
    g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
    fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
    window.Repaint();
}
function on_mouse_move(x,y){
    if(g_drag){
        g_drag_seek = x / window.Width;
        g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
        window.Repaint();
    }
}

function on_playback_new_track(info){
    window.Repaint();
}

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

function on_playback_seek(time){
    window.Repaint();
}

function on_playback_time(time){
    window.Repaint();
}
//EOF

WSH Panel Mod script discussion/help

Reply #144
Thank you,is very good.anything for playbak order? I ask too much... 

WSH Panel Mod script discussion/help

Reply #145
the playback controls and background are panel stack splitter. the volume control, seekbar and playback order button are 3 separate WSH scripts. you can right click those, select configure to open the editor and then export the contents to a text file. or you can use the columns UI layout page to copy panels between layouts. i


I tried that but it is not possible to remove borders for wsh panel, I thought there would be a way to draw the whole thing using one wsh panel

WSH Panel Mod script discussion/help

Reply #146
marc can you please provide a snippet to convert the play button into a play/pause button. I have no idea how to switch images and I am using the layout
< || >
Thanks

WSH Panel Mod script discussion/help

Reply #147
I thought there would be a way to draw the whole thing using one wsh panel


that's way beyond my capabilities.   

as for the buttons, i already told you, they're done in panel stack splitter for that config. there isn't much need to make buttons in WSH panel mod when you're using columns UI/PSS because you already have much easier ways (using standard columns UI toolbar or $imagebutton in PSS).

WSH Panel Mod script discussion/help

Reply #148
Here is something that might come in handy, but I don't know exactly what your script looks like Icedtea so it probably won't work without some tweaking.

Code: [Select]
function on_playback_stop()
{
    buttons.pop.icon=gdi.Image(dir+"play"+".png");
    buttons.pop.tooltiptxt="Play";
    window.Repaint();
}
function on_playback_pause(is_paused)
{
    buttons.pop.icon=is_paused?gdi.Image(dir+"play"+".png"):gdi.Image(dir+"pause"+".png");
    buttons.pop.tooltiptxt=is_paused?"Play":"Pause";
    window.Repaint();
}
function on_playback_starting(cmd, is_paused)
{
    buttons.pop.icon=is_paused?gdi.Image(dir+"play"+".png"):gdi.Image(dir+"pause"+".png");
    buttons.pop.tooltiptxt=is_paused?"Play":"Pause";
    window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #149
I thought there would be a way to draw the whole thing using one wsh panel


that's way beyond my capabilities.   

as for the buttons, i already told you, they're done in panel stack splitter for that config. there isn't much need to make buttons in WSH panel mod when you're using columns UI/PSS because you already have much easier ways (using standard columns UI toolbar or $imagebutton in PSS).


sorry for the confusing message
What I meant was in the button example in your samples is there a way to convert the play button to a Play/Pause button. The function replacement fb.PlayOrPause() works ok but I have no idea on how to switch the images between play and pause i.e. when the playback is paused the button should be play.png and when the song is playing the button should be pause.png, with the hover effects of course.
Thanks