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 820028 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #175
TomBarlow, can you help me inserting your wheel-scrolling function in my progress bar script?
Code: [Select]
// Flags, used with GdiDrawText
  // For more information, see: [url=http://msdn.microsoft.com/en-us/library/dd162498(VS.85).aspx]http://msdn.microsoft.com/en-us/library/dd162498(VS.85).aspx[/url]
  var DT_TOP = 0x00000000;
  var DT_LEFT = 0x00000000;
  var DT_CENTER = 0x00000001;
  var DT_RIGHT = 0x00000002;
  var DT_VCENTER = 0x00000004;
  var DT_BOTTOM = 0x00000008;
  var DT_WORDBREAK = 0x00000010;
  var DT_SINGLELINE = 0x00000020;
  var DT_EXPANDTABS = 0x00000040;
  var DT_TABSTOP = 0x00000080;
  var DT_NOCLIP = 0x00000100;
  var DT_EXTERNALLEADING = 0x00000200;
  var DT_CALCRECT = 0x00000400;
  var DT_NOPREFIX = 0x00000800;
  var DT_INTERNAL = 0x00001000;
  var DT_EDITCONTROL = 0x00002000;
  var DT_PATH_ELLIPSIS = 0x00004000;
  var DT_END_ELLIPSIS = 0x00008000;
  var DT_MODIFYSTRING = 0x00010000;
  var DT_RTLREADING = 0x00020000;
  var DT_WORD_ELLIPSIS = 0x00040000;
  var DT_NOFULLWIDTHCHARBREAK = 0x00080000;
  var DT_HIDEPREFIX = 0x00100000;
  var DT_PREFIXONLY = 0x00200000;
 
  function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
 
  var g_font = gdi.Font("LCD", 18, 1);
  var g_drag = 0;
  var g_drag_seek = 0;
  var tfo = fb.TitleFormat("POS: %playback_time%/%length% '('$max(0,$left($muldiv(%playback_time_seconds%,1000,%length_seconds%),$sub($len($muldiv(%playback_time_seconds%,1000,%length_seconds%)),1)))'.'$right($muldiv(%playback_time_seconds%,1000,%length_seconds%),1)'%)' REM: %playback_time_remaining%");
     
 
  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);
  }
 
  function on_paint(gr){
      var txt = "";
      var pos =0;
             
      if(fb.PlaybackTime > 0){
          if(g_drag){
              pos = window.Width * g_drag_seek;
              txt = "Seek " + TimeFmt(g_drag_seek * fb.PlaybackLength) + " / " + TimeFmt(fb.PlaybackLength);
          }
          else{
              pos = window.Width * (fb.PlaybackTime / fb.PlaybackLength);
              txt = tfo.Eval();
          }
 
      }else
      {
      txt = "Playback Stopped";
      }
     
     
      gr.FillGradRect(  0, 0,    pos, window.Height, 90, RGB(240,240,240), RGB(46,48,63));
      gr.FillGradRect(pos, 0, window.Width-pos, window.Height, 90, RGB(240,240,240), RGB(190,190,190));
      gr.GdiDrawText(txt, g_font, RGB(50,50,50), 0, 0, window.Width, window.Height, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
      gr.DrawRect(0,0, window.Width-1, window.Height-1, 1.0, RGB(150,150,150));
  }
 
  function on_mouse_lbtn_down(x,y){
      g_drag = 1;
  }
 
  function on_mouse_lbtn_up(x,y){
      if(g_drag){
          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;
      }
  }
 
  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_time(time){
      window.Repaint();
  }
 
  function on_playback_stop(){
          window.Repaint();
  }
 
  function on_playback_starting(cmd, paused){
  }
  function on_playback_new_track(info){
      window.Repaint();
  }
  //EOF

WSH Panel Mod

Reply #176
You just need to add this bit to the bottom:

Code: [Select]
//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");
}


You could use a different seek command if you want.

tedgo: Not sure what the best place is... on_playback_time is probably OK. Maybe on_playback_new_track? I don't know really, I guess as long as it fixes it it doesn't matter too much.


WSH Panel Mod

Reply #178
@TomBarlow
Thanks for the hint.
I'll try to place it in other functions and will see what happens
I only thought when i update my panel 25 times a second (with 40ms interval) CollectGarbage(); may perhaps be executed too often in on_playback_time. That for i asked for a better place for it.

WSH Panel Mod

Reply #179
Sorry but I need to ask...

Are there any plans for foo_ui_wsh?

<insert signature here>

WSH Panel Mod

Reply #180
@Developer
I remember back in the old days of the first WSH panel, the background never repainted by itself (thus showing 'garbage' and forcing us to paint correctly)

Is there a way to stop the autofilling background?

Thanks!
<insert signature here>

WSH Panel Mod

Reply #181
I was wondering if there is a way to control the speaker volume of the computer via WSH panel. I have already made a slider which controls the regular foobar volume, but I also want a volume slider for the "master volume." If there is a way to do this, how would I go about doing such a thing?

WSH Panel Mod

Reply #182
Hi, I was told in another tread that WSH Panel Mod would be able to give me a rating system a la Media Monkey with 5 stars (or other icon) but in HALF increments so I can do half stars. So basically 10 increments as opposed to the default 5. Anyone know how to do that?
I use Columns UI

WSH Panel Mod

Reply #183
I just started using WSH Panel Mod and it's a little overwhelming at first. I really think there should be more samples included in the download. There's a volume bar, and that's great, but another thing most people will want to use WSH Panel Mod for is a seekbar. So, judging from my view as a beginner, I strongly recommend to include at least a seekbar sample.

WSH Panel Mod

Reply #184
You can find a seekbar sample already in this thread. Modifications can be found here and here

WSH Panel Mod

Reply #185
I need some help from math experts. I used the function
Code: [Select]
function pos2vol(pos) {
     return (50 * Math.log(0.99 * ((pos<0) ? 0 : (pos<1) ? pos : 1) + 0.01) / Math.LN10);
};
//(pos is a percentage of the volume bar width, between 0 and 1)
to get logarithmic volume bar behavior, like foobar2000's default volume bar has.

But I don't know how to code the opposite function, vol2pos(vol). Can somebody please help me out here?[/s]

Edit: I saw this function is in the third link you provided, thanks fbuser.

WSH Panel Mod

Reply #186
Is it possible with WSH Panel Mod to find out the track titel of the song that's about to be played next, and also the song that has been played before?

WSH Panel Mod

Reply #187
Has anyone tried building a complete UI using this yet?

I'm sure this component could be implemented as a complete UI replacement (instead of Columns UI) which would make possible designing complete user interfaces using JScript.
This would finally end the nonsense components like panel stack splitter and family.

 

WSH Panel Mod

Reply #188
Would be cool if someone did that. He'd be my hero.

Question:
How to tell WSH Panel Mod to refresh more often than every second? I would like to have a very smooth seekbar. Currently I use this:
Code: [Select]
function on_playback_time(){
    window.Repaint();
}

But that is too choppy, especially when it comes to playing songs that have short length.

WSH Panel Mod

Reply #189
Would be cool if someone did that. He'd be my hero.

Question:
How to tell WSH Panel Mod to refresh more often than every second? I would like to have a very smooth seekbar. Currently I use this:
Code: [Select]
function on_playback_time(){
    window.Repaint();
}

But that is too choppy, especially when it comes to playing songs that have short length.


you have a jscript example (for a seekbar) given in post #170 : http://www.hydrogenaudio.org/forums/index....st&p=639235


WSH Panel Mod

Reply #190
Thanks, here's the important piece of code:
Code: [Select]
var g_timer;

function on_playback_time(){
    if(g_timer){window.KillTimer(g_timer);}
    if(fb.PlaybackLength>0){g_timer = window.CreateTimerInterval(100);}
    window.Repaint();
}
function on_timer(){
    window.Repaint();
}

WSH Panel Mod

Reply #191
Correct me if I'm wrong, but the code provided in the link is not the best/fastest solution, is it? I altered it to this:
Code: [Select]
var timer;

function on_playback_starting(){
    timer = window.CreateTimerInterval(100);
}
function on_playback_stop(){
    if(timer){window.KillTimer(timer);}
    window.Repaint();
}
function on_timer(){
    window.Repaint();
}

I also completely removed the function on_playback_time().
Is this the best possible code that covers all kinds of situations without errors? I want to have the best CPU performance and no memory leaks.
Forgive me if this is a minor problem for you, but I'm just starting with this and want to learn it the proper way right from the start.

Another problem is that the bar hangs after Playback Stop. It is not reset to the start. How to fix?

WSH Panel Mod

Reply #192
I don't really understand the function CollectGarbage(). How to tell which parts of the code create garbage? I'd say for large playlists, it should be best to place the garbage collector into this function:
Code: [Select]
function on_playback_new_track(){
    CollectGarbage();
}

Does everyone agree?

Edit: Another performance question:
Considering the seekbar has a rectangular border with the size of 1 pixel, is it faster or slower to use the function RepaintRect(1,1,ww-2,wh-2) rather than Repaint()?
(ww = variable with windows.Width value; wh = variable with windows.Height value)

WSH Panel Mod

Reply #193
Am I the only one who's not able to show properly the info providen by Shoutcast streams on this panel?

I ask because I'm using a WSH panel to show info and if I do something like:

Code: [Select]
...
/// SHOWING RELEVANT STUFF
g_metadb = fb.GetNowPlaying();
...
this.string = fb.TitleFormat(string).EvalWithMetadb(g_metadb);
...
gr.GDIDrawText(this.string, g_font, this.Ncolor, this.x+this.pad, this.y, this.w-this.pad*2, this.h,1);
....


...and play local stuff, all the output it's OK, but If I play streams like a shoutcast station, things like %artist% will output a "?". The weird part is that I saw the right values in the Lyrics show panel and the CUI caption bar, even the Biography View retrieved the correct info.

How can I correct this behaviour?
<insert signature here>

WSH Panel Mod

Reply #194
Sorry I have no answer, but another question:

Does WSH Panel Mod make it possible to tell foobar2000 to create a new playlist based on kind of a search string?

Please tell me if you know something.

WSH Panel Mod

Reply #195
Has anybody noticed/experienced the text that is drawn in a wsh_panel to be blocky/pixel-y sometimes? The text seems fine for a while, and then when I restart it, it gets all weird looking. 

it looks like this right now (I know it's small but maybe you can notice if you look hard enough ):

WSH Panel Mod

Reply #196
xbullethammer: You need to use Eval(), and then redraw under on_playback_dynamic_info_track(). You can do something like this.string = fb.IsPlaying?fb.TitleFormat(string).Eval():fb.TitleFormat(string).EvalWithMetadb(g_metadb);

Harun: use gr.SetTextRenderingHint(5);

durch: I don't think it's possible. I'm not sure about collect.garbage either, on_playback_new_track() is probably OK.

Oh and I tweaked my seekbar, now it redraws like this:

Code: [Select]
function on_playback_time(time)
{
if(g_timer){window.KillTimer(g_timer);}
if(fb.PlaybackLength>0){g_timer = window.CreateTimerInterval(40);}
window.Repaint();
}
function on_playback_stop()
{
CollectGarbage();
if(g_timer){window.KillTimer(g_timer);}
window.Repaint();
}
function on_playback_pause(state)
{
window.Repaint();
}
function on_playback_starting(cmd, is_paused)
{
CollectGarbage();
g_timer = window.CreateTimerInterval(40);
window.Repaint();
}
//Redraw more than once per sec
function on_timer(id)
{
window.RepaintRect(pos-2*seekerwidth,0,4*seekerwidth,window.Height);
}

It might not look quite right with really short songs and a long seekbar. You might have to adjust the rectangle that's redrawn.

WSH Panel Mod

Reply #197
@TomBarlow: I think you can erase the whole on_playback_time() function. I don't know who introduced this first, but it doesn't make any sense to me and works great without it as far as I can tell. It's just unnecessary to create and kill a timer every second when you already did that on playback start/stop.

Also, I think on_playback_pause() doesn't need a repaint, because the timer is still running in the background.

Correct me if I'm wrong. I just like to know that everything is as fast and compact as possible.

WSH Panel Mod

Reply #198
Quote from: TomBarlow link=msg=0 date=
... You need to use Eval(), and then redraw under on_playback_dynamic_info_track(). You can do something like this.string = fb.IsPlaying?fb.TitleFormat(string).Eval():fb.TitleFormat(string).EvalWithMetadb(g_metadb);


OK man I'll try it as soon as I can.
<insert signature here>

WSH Panel Mod

Reply #199
This might be a dumb question, but how do I access extended variables via jscript? I tried fb.varname varname and %varname% and neither did work :/