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 (Read 814816 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod

Reply #150
Youn can use this:

Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.run("http://en.wikipedia.org/wiki/"+fb.TitleFormat("$replace(%artist%,' ','_')").Eval(true));

WSH Panel Mod

Reply #151
For someone who has little programming experience it seems to be quite complicated to work with tags... so I have some questions and I'm sure there are people here who can explain me.

I undertand how to get the focussed item and how to use fb.TitleFormat, but I don't know how to do these things:
    Check whether one of the multiple values in a specific tag field is a specific value or not. For example: if the tag "Genre" has a field called "jazz".
    Add a value to a tag field.
    Remove a value from a tag field.
    Add multiple values.
    Remove all values.[/li]

Who can help me?


WSH Panel Mod

Reply #153
I have a slight problem, which is, on_item_focus_change isn't called on playlist change, and fb.GetNowFocused isn't updated either, which means it's impossible to focus a track (and e.g. show it's artwork) when changing to a playlist with only one track in. Is there any way round that?

Cheers.

WSH Panel Mod

Reply #154
I don't think so ... and it is consistent with the rest of foobar. You'll have to select the track manually.

WSH Panel Mod

Reply #155
But that's the problem (I wasn't quite clear on that I think), selecting it doesn't focus it, so WSH panel doesn't know I want to look at the album art for that track, so I can't view the album art for it at all unless I play it.

WSH Panel Mod

Reply #156
I figured out myself how working with tags from wsh panel mod works, so I don't need answer to my question on that anymore, except for one thing: how do I write multiple values to one field?

I use an IFbFileInfo object as described in Interfaces.txt:
Quote
interface IFbFileInfo {
Properties:
   (readonly) int MetaCount;
   (readonly) int InfoCount;

Methods:
   int MetaValueCount(idx);
   int MetaFind(name); // New, return idx
   int InfoFind(name); // New, return idx
   String MetaName(idx);
   String MetaValue(idx, vidx);
   String InfoName(idx);
   String InfoValue(idx);
   void MetaSet(name, value); // New
}


With MetaValue(idx, vidx) I can read individual values, but MetaSet(name, value) accepts only one value. MetaSet(name, value1, value2) gives an error (Wrong number of arguments or invalid property assignment) and using an array as value results in a single value with the different values that were in the array separated by commas.
So my question is: is there another way to write multiple values to one field?

WSH Panel Mod

Reply #157
I've not tested it but I think a semicolon is what you want, try MetaSet(name, value1+";"+value2).

About my last point: I think fb.GetFocusItem is updated on playlist change but on_item_focus_change() isn't called. So when there's only one track in the playlist, clicking on it doesn't change the focused item, so on_item_focus_change() never gets called. Would it be possible to have an on_playlist_change() callback?

Thanks.


WSH Panel Mod

Reply #159
- I´d like to add the function to switch the skip option (Menu/Playback/Skip) in the PBOButton script, so that when in Playback (shuffle) mode, skip is turned on and for all other modes it is turned off.

So what I found is something like RunMainMenuCommand(playback.skip), but where do I have to put it to be executed together with the PBO command?

And is it possible to turn it on and off with CheckMenuItem(item_id, check); ?

- I would also like to make a WSH panel which has an imagebutton to simulate a keystroke (arrow left or right) to trigger the cover flow of a Chronflow panel. Is that possible and how?

Sorry for now I don´t have much of an idea of jScript


WSH Panel Mod

Reply #161
WSH Panel Mod 1.1.8 Released.

WSH Panel Mod

Reply #162
Thanks for the new callbacks
Something new to play with.


WSH Panel Mod

Reply #164
Hey guys, having a bit of a problem with (I presume) WSH_panel_mod and a skin I downloaded.

Ok, so details...

Problem exists with both 0.9.6.5 and 0.9.6.7. And with foo_uie_wsh_panel_mod-1.1.7 and 1.1.8.

Skin is Monolite and can be found at http://fanco86.deviantart.com/art/MonoLite-122756120

My installed components are these:


All I get is this:

Couldn't find a solution to my problem anywhere... :<

WSH Panel Mod

Reply #165
Looks like you don't have the skin in the correct location.

You can either edit the location in each and every panel or make sure the skin is in C:\Program Files\foobar2000\skin\, so in the skin folder should be a folder called mono_lite and the mono_lite.fcl file.

WSH Panel Mod

Reply #166
Aah, I see, thanks very much. I assumed you could just navigate to the folder and import the fcl and the references would be relative to that location... working perfectly now. Thanks!

WSH Panel Mod

Reply #167
1.1.8 version looks like no my problem with trash on background. Thanks

WSH Panel Mod

Reply #168
Wasn't there somewhere a sample with a seekbar that uses a shorter timer interval?
I can't find it any longer...

WSH Panel Mod

Reply #169
Hmm maybe. Try this one. It has mouse wheel seeking and stuff as well. You'll have to change the images on lines 48-54.

Code: [Select]
var dir = fb.FoobarPath+"\\images\\FOOTOR\\";
//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);
}
//Time formatting
function TimeFmt(t){
var zpad = function(n){
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}
var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}
StringAlignment = {
Near: 0,
Centre: 1,
Far: 2
};
var font = gdi.Font("Calibri", 10, 1);
var l_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Centre);
var c_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Centre);
var r_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Centre);

var g_drag = 0;
var g_drag_seek = 0;
var g_drag_hov = 0;
//The seekbar
var L = gdi.Image(dir+"L.png");
var R = gdi.Image(dir+"R.png");
var seeker = gdi.Image(dir+"seeker2.png");
//background
var bg = gdi.Image(dir+"btn_m.png");
var bgL = gdi.Image(dir+"btnbg_l.png");
var bgR = gdi.Image(dir+"btnbg_r.png");

var ww = window.Width;
var wh = window.Height;
//Titleformatting
var len = fb.Titleformat("%length%");
var elap = fb.TitleFormat("%playback_time%");
var remain = fb.TitleFormat("$if2(%playback_time_remaining%,wat)");

var tooltip = window.CreateTooltip();

var pos = 0;
var seekstart = 0;
var seekend = 0;
var seekpad = 6;
var seekerwidth = seeker.Width/2;

var g_timer;

function on_paint(gr)
{
gr.SetTextRenderingHint(5);
gr.DrawImage( bg, 0, 0, window.Width, bg.Height, 0, 0, bg.Width, bg.Height);
//For normal playback
if(fb.PlaybackLength>0)
{
seekstart = gr.CalcTextWidth(len.Eval(),font);
seekend = gr.CalcTextWidth(len.Eval(),font);
gr.DrawImage( L, seekstart+seekpad, 2, window.Width-(seekstart+seekend+2*seekpad)-R.Width, 16, 0, 0, window.Width-(seekstart+seekend+2*seekpad)-R.Width, 16);
gr.DrawImage( R, window.Width-(seekend+seekpad)-R.Width, 2, 2, 16, 0, 0, 2, 16);
gr.DrawString(elap.Eval(), font, 0xff000000, 3, 0, seekstart+seekpad, 18, l_stringformat);
gr.DrawString(remain.Eval(), font, 0xff000000, ww-seekend-3-seekpad, 0, seekend+seekpad, 18, r_stringformat);
if(g_drag)
{
pos = seekstart+seekpad+seekerwidth+(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth))) * g_drag_seek;
}
else
{
pos = seekstart+seekpad+seekerwidth+(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth))) * (fb.PlaybackTime / fb.PlaybackLength);
}
gr.DrawImage( seeker, pos-seekerwidth, 2, 12, 16, 0, 0, 12, 16);
if(g_drag_hov)
{
gr.DrawImage(bgL, 0, 0, bgL.Width, bgL.Height, 0, 0, bgL.Width, bgL.Height);
gr.DrawImage(bgR, window.Width-bgR.Width, 0, bgR.Width, bgR.Height, 0, 0, bgR.Width, bgR.Height);
}
}
//For streams
else if(fb.IsPlaying && fb.PlaybackLength)
{
seekstart = 0;
seekend = 0;
gr.DrawString(elap.Eval()+" / continuous", font, 0xff000000, 0, 0, window.Width, 18, c_stringformat);
if(g_drag_hov)
{
gr.DrawImage(bgL, 0, 0, bgL.Width, bgL.Height, 0, 0, bgL.Width, bgL.Height);
gr.DrawImage(bgR, window.Width-bgR.Width, 0, bgR.Width, bgR.Height, 0, 0, bgR.Width, bgR.Height);
}
}
}

function on_size()
{
ww = window.Width;
wh = window.Height;
}

function on_mouse_lbtn_down(x,y)
{
if(x>seekstart+seekpad&&x<window.Width-(seekend+seekpad))
{
if(fb.PlaybackLength){g_drag = 1;}
g_drag_seek = (x>seekstart+seekpad+seekerwidth)?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth)))x<(window.Width-(seekend+seekpad+seekerwidth)))?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth))):1;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
}
window.Repaint();
}

function on_mouse_move(x, y)
{
g_drag_hov = true;
if(fb.IsPlaying&&fb.PlaybackLength>0&&x>seekstart&&x<window.Width-seekend)
{
g_drag_seek = (x>seekstart+seekpad+seekerwidth)?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth)))x<(window.Width-(seekend+seekpad+seekerwidth)))?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth))):1;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
tooltip.Text = TimeFmt(fb.PlaybackLength * g_drag_seek);
tooltip.Activate();
}
else
{
tooltip.Deactivate();
}
window.Repaint();
}

function on_mouse_lbtn_up(x, y)
{
if(g_drag)
{
g_drag = 0;
g_drag_seek = (x>seekstart+seekpad+seekerwidth)?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth)))x<(window.Width-(seekend+seekpad+seekerwidth)))?(x-(seekstart+seekpad+seekerwidth))/(window.Width-(seekstart+seekend+2*(seekpad+seekerwidth))):1;
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_leave()
{
g_drag_hov = false;
tooltip.Deactivate();
window.Repaint();
}

function on_playback_seek(time)
{
window.Repaint();
}
function on_playback_time(time)
{
if(g_timer){window.KillTimer(g_timer);}
if(fb.PlaybackLength>0){g_timer = window.CreateTimerInterval(100);}
window.Repaint();
}
function on_playback_stop()
{
if(g_timer){window.KillTimer(g_timer);}
window.Repaint();
}
function on_playback_pause(state)
{
window.Repaint();
}
function on_playback_starting(cmd, is_paused)
{
g_timer = window.CreateTimerInterval(100);
window.Repaint();
}
//Redraw more than once per sec
function on_timer(id)
{
window.Repaint();
}
//Seek using mouse wheel
function on_mouse_wheel(delta){
if(delta>0)
fb.RunMainMenuCommand("Seek Ahead by 10 Seconds");
else
fb.RunMainMenuCommand("Seek Back by 10 Seconds");
}

WSH Panel Mod

Reply #170
Thank you

WSH Panel Mod

Reply #171
@TomBarlow
I tried your sample now and it works great (changed only minor things ).
But memory load raises up gigantic...

What's the best place for "CollectGarbage()"?
I tried with on_playback_time and it seems to be ok now, but i don't know if its the best place for it...

WSH Panel Mod

Reply #172
Hmm not sure. I didn't think there was much garbage that needs collecting... It works OK for me, my foobar is on ~3% CPU while playing. Did you change the redraw interval? I have it on 100ms. Maybe try increasing it?

WSH Panel Mod

Reply #173
Is there a way to access gr from a callback like on_mouse_move()?

I made some buttons on a fairly large panel, and I don't want to repaint the whole window to update a tiny part of it.

I'm trying to do this:

Code: [Select]
function on_mouse_move(x, y) {
    var btn_found = false;
    for (var i in $buttons) {
        if ($buttons[i].containXY(x, y) && $buttons[i].state != ButtonStates.hide) {
            $buttons[i].state = ButtonStates.hover;
            cur_btn = $buttons[i];
            btn_found = true;
        } else {
            $buttons[i].state = ButtonStates.normal;
        }
    }
//    window.Repaint();/* <<<< BAD */
    drawAllButtons(gr);/* <<<<<<  This should paint the buttons */
}


It's obvious that the callback doesn't know what gr is  . Any workarounds?
<insert signature here>

 

WSH Panel Mod

Reply #174
@TomBarlow
Yes, i changed redraw interval to 40ms, but also tried with 100ms.
In both cases ram usage raised up at about 2-3mb per track without CollectGarbage();
It sums up when hearing a whole playlist

Didn't raise with CollectGarbage(); though, but i don't know if there's a better place for it than on_playback_time(time).

I realized higher CPU load with my 40ms of course (three times high  ) but it is much more "runny" with it.

@xbullethammer
Why don't you use window.RepaintRect(x,y,w,h) for your buttons area only?