Skip to main content

Topic: WSH Panel Mod script discussion/help (Read 843694 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Emerelle
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #1975
Awesome new samples Marc! Many thanks for the new sample and changing your mind

One more question about adjusting the tag script...if I want to have a transparent background, I tried disabling the line "p.draw_background(gr);" but that seems to break the script. In the simple text reader script this worked for me though.
Any quick way to make the background transparent?

Again, many thanks for your hard work, love all of your samples.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1976
Quote
I tried disabling the line "p.draw_background(gr);" but that seems to break the script.


are you sure?    add double backslashes to comment it out and the text should turn green in the editor. or just delete it....
  • Last Edit: 11 January, 2013, 04:14:16 AM by marc2003

  • Emerelle
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #1977
I always use double slash for commenting things out - the panel turned white causing me thinking I broke it with the comment; anyways I only forgot to tick "transparent background" in the editor - sorry mate!!

  • Yeksfys
  • [*]
WSH Panel Mod script discussion/help
Reply #1978
marc2003 this can serve to "Custom folder" in your scripts. 

Code: [Select]
//Flags  http://msdn.microsoft.com/en-us/library/bb773205.aspx
var BROWSEINFO_FLAG = 0x00000010 // BIF_EDITBOX

function showFolderDialog() {
    var shell = new ActiveXObject("Shell.Application");
    var folder = shell.BrowseForFolder(0, "Select the folder", BROWSEINFO_FLAG);
    
    if (folder == null) {
        return;
    }
    
    return folder.items().item().path;
}

fb.trace(showFolderDialog());

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1979
nice, i didn't know you could do that sort of thing.

but it's not really any use for my scripts because it would be extremely rare for anyone to specify a hardcoded single folder. most people will be using foobar2000 title formatting so the folder names are dynamic based on track metadata.

  • motorhorst
  • [*]
WSH Panel Mod script discussion/help
Reply #1980
I have an idea for a script but I'm not sure if this is possible, maybe someone could comment on that.

I keep my playlists in a central container (e.g. a dropbox folder) and would like to use them on several computers (filepaths / libraries are the same on all machines).

I'd like a script that lists all playlists in that folder. By clicking on one of these files in foobar that list should be added as a playlist (and played, but that isn't the most important part).

As far as I see it, I need these functions:
- Read all files in a directory/folder
- File > Load Playlist after clicking the title of one file (something like fb.RunMainMenuCommand with the selected playlist as filename).

Is that possible?

  • motorhorst
  • [*]
WSH Panel Mod script discussion/help
Reply #1981
Version 2:

There is another way how I could tackle my problem.
I can get my playlists via a web service (they're saved to a mysql-Database).

Then I could create a new playlist and add all the items sent as json.

In this case the functions I need are:
- Create a new playlist
- Add items to a specific playlist.

Is this possible? Easier than my first request?

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1982
i'm not sure why you don't get dropbox to monitor your normal playlists folder? then you can use the default playlist manager??? 

but if you really want to add a new playlist....

Code: [Select]
fb.RunMainMenuCommand("New playlist");


then look at utils.glob for getting all files from a folder into an array. then loop through the array for displaying and mouse click code. then run foobar2000.exe with the /add parameter to the full path of one of your playlists.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1983
samples updated: use Update script on the context menu or the full download is here: http://db.tt/BInQ3Abm

last.fm charts: fix crash when switching between populated and empty feeds.
artreader / simple image viewer: open containing folder did not work when path had spaces in. 

files changed:
Code: [Select]
marc2003\common6.js
  • Last Edit: 17 January, 2013, 05:01:28 AM by marc2003

  • motorhorst
  • [*]
WSH Panel Mod script discussion/help
Reply #1984
i'm not sure why you don't get dropbox to monitor your normal playlists folder? then you can use the default playlist manager??? 


Hi marc,
great idea, maybe too obvious for me...
Part 1 on computer 1 worked fine, I just have to check at home how it works out.

Edit/Resolved
Does anyone know where playlist organizer saves changes to folders, structures, order? Also in the playlists folder or somewhere else?
Answer: It's stored in theme.fth


Thanks for your help!
  • Last Edit: 17 January, 2013, 07:35:43 AM by motorhorst

  • MDMA
  • [*][*]
WSH Panel Mod script discussion/help
Reply #1985
samples updated: http://db.tt/BInQ3Abm

new script: discogs

this is a quick and dirty bodge so report any bugs. it only contains master releases and will only display the first 100. i won't be adding support for pagination.
i looked at using releases to get more results but that can return thousands of hits for popular artists so i ditched that idea...



files added/changed:
Code: [Select]
marc2003\common6.js
samples\discogs.txt


@ngonngon, use utils.GetAlbumArtEmbedded to always prefer embedded art. using the other methods, the core artreader may decide other images are better.



You are a hero, thanks so much for this!

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1986
samples updated: use Update script on the context menu or the full download is here: http://db.tt/BInQ3Abm

news/reviews/blogs: fix ugly text drawing bug
last.fm similar artists: the top tags feed now has autoplaylist buttons to search your library for matching files against genre tags.

files changed:
Code: [Select]
marc2003\common6.js


although i try not to change panel scripts very much (as most code is in the common file), i've made a few minor changes over the last few days. you can check the versions here: http://dl.dropbox.com/u/22801321/wsh/versions.txt


  • nikolai4ik
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #1987
Hey guys, would really appreciate some help. I've updated from 1.3.x to the current version and two panels stopped working for me (aw crashed), volume and seekbar.
Maybe somene can quickly glance over it and find the corrupt code?
Code: [Select]
// Knob button by Br3tt
// Modified by T.P Wang

function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

var g_drag = false;
// foobar path, SHOULD be replaced
var g_btn_img1 = gdi.Image(fb.ComponentPath.replace("components","images") + "curacao/bt/volbutton50.png");
var g_btn_img2 = gdi.Image(fb.ComponentPath.replace("components","images") + "curacao/bt/voldot.png");

var g_angle = 270;
var g_R = 12;

function calc_theta(x,y){
x = x - 25.5;
y = y - 25.5;
theta = Math.atan2(y,x) / Math.PI * 180;
if (theta <= 90 && theta > 45)
return g_angle;
if (theta > 90 && theta < 135)
return 0;
if (theta >= 0) {
if (theta > 90)
return theta - 135;
else
return theta + 225;
} else {
return theta + 225;
}
}

function on_paint(gr){
ww = window.Width;
wh = window.Height;
theta = (Math.pow(10, fb.Volume / 50) - 0.01) / 0.99 * g_angle;
// Volume 'Round Button' by Br3tt (13-08-2008)
posA = (theta - 45) * Math.PI / 180;
cosinusA = Math.cos(posA);
sinusA = Math.sin(posA);
posX = 25 - (cosinusA * 12) - 4 ;
posY = 25 - (sinusA * 12) - 4 ;
gr.FillGradRect( 0, 0, ww, wh, 90, RGB(042,042,047), RGB(042,042,047));
gr.DrawImage(g_btn_img1,-4,-4,55,55,0,0,55,55);
gr.DrawImage(g_btn_img2,posX,posY,5,5,0,0,5,5);
}

function on_mouse_lbtn_down(x,y){
g_drag = true;
}

function on_mouse_lbtn_up(x,y){
on_mouse_move(x,y);
g_drag = false;
}

function on_mouse_move(x,y){
if (g_drag){
// Calc Volume
d = calc_theta(x,y) / g_angle;
v = 50 * Math.log(0.99 * d + 0.01) / Math.LN10;
if (fb.Volume != v)
fb.Volume = v;
}
}

function on_mouse_wheel(delta){
if(delta>0)
fb.VolumeUp();
else
fb.VolumeDown();
}

function on_volume_change(val){
window.Repaint();
}

//EOF


Code: [Select]
var weight_normal =400;
var weight_bold  =800;
var italic_no =0;
var italic    =1;
var uline_no  =0;
var uline    =1;
//--------
var align_top  =0;
var align_middle=1;
var align_bottom=2;

var align_left  =0;
var align_center=1;
var align_right =2;

var trim_no    =0;
var trim_chara  =1;
var trim_word  =2;
var trim_elips_chara =3;
var trim_elips_word  =4;
var trim_elips_path  =5;

var flag_rtl        =0x0001;
var flag_vert      =0x0002;
var flag_nofit      =0x0004;
var flag_dispctrl  =0x0020;
var flag_nofallback =0x0400;
var flag_trailspace =0x0800;
var flag_nowrap    =0x1000;
var flag_linelimit  =0x2000;
var flag_noclip    =0x4000;

var g_btn_img1 = gdi.Image(fb.ComponentPath.replace("components","images") +

"curacao/bt/seeker10.png");

function StrFmt(alignH,alignV,trim,flag){ return ((alignH<<28)|(alignV<<24)|(trim<<20)|flag);

}
//--------
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r,g,b,a){ return ((a<<24)|(r<<16)|(g<<8)|(b)); }
//--------
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);
}
//----------------------------------------------------------------------------
var g_titlefmt = fb.TitleFormat("");
var g_fileinfo = null;

var g_drag = 0;
var g_drag_seek = 0;

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

ww = ww-20;

if(length > 0){
if(g_drag){
pos = ww * g_drag_seek;
txt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt

(length) + 00;
}
else{
pos = ww * (fb.PlaybackTime / length) + 00;
txt = g_titlefmt.Eval();
}
}

// background
gr.FillGradRect( 0, 0, window.Width+2, window.Height+2, 90, RGB(042,042,047), RGB

(042,042,047));

gr.FillGradRect( 11, 04, window.Width-22, 3, 90, RGB(0,0,0), RGB(0,0,0));

// orange progress bar
//gr.FillGradRect( 10, 04, pos+1, 3, 90, RGB(220,155,75), RGB(080,055,25));
//blue progress bar
gr.FillGradRect( 10, 04, pos+1, 3, 90, RGB(035,145,255), RGB(025,055,080));
//green progress bar
//gr.FillGradRect( 10, 04, pos+1, 3, 90, RGB(055,255,055), RGB(065,080,065));

gr.FillGradRect( 10, 03, window.Width-20, 1, 90, RGB(010,010,010), RGB(010,010,010));

gr.FillGradRect( 10, 08, window.Width-20, 1, 90, RGB(070,070,070), RGB(070,070,070));
gr.FillGradRect( 09, 04, 1, 4, 90, RGB(000,000,000), RGB(000,000,000));
gr.FillGradRect( window.Width-10, 4, 1, 4, 90, RGB(060,060,060), RGB(060,060,060));

gr.DrawImage(g_btn_img1,pos+2,1,17,17,0,0,17,17);

}

function on_size(){
}

function on_focus(gr){
//fb.trace("focus " + focused);
}

function on_key_down(key){
//fb.trace("key " + key);
}
function on_mouse_lbtn_down(x,y){
g_drag = 1;
}
function on_mouse_lbtn_up(x,y){
if(g_drag){
x = x-10;
g_drag = 0;
g_drag_seek = x / (window.Width-20);
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){
x = x-10;
g_drag_seek = x / (window.Width-20);
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
window.Repaint();
}
}
function on_mouse_wheel(delta){
//fb.trace("wheel " + delta);
}
//--------
function on_playback_starting(cmd, paused){
}
function on_playback_new_track(info){
window.Repaint();
}
function on_playback_stop(){
window.Repaint();
}
function on_playback_seek(time){
window.Repaint();
}
function on_playback_pause(state){
}
function on_playback_edited(){
}
function on_playback_dynamic_info(){
}
function on_playback_dynamic_info_track(){
}
function on_playback_time(time){
window.Repaint();
}
function on_volume_change(val){
}

//EOF

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1988
i can't see anything in the code that wouldn't work in new versions. are you sure you have the external images in the right place?

  • nikolai4ik
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #1989
i can't see anything in the code that wouldn't work in new versions. are you sure you have the external images in the right place?

Yes, nothing changed except the update of wsh plugin and I just rechecked with another path. I found the same knob script posted by Wang somewhere earlier in the thread and strangely it works (despite being the same). No luck with seekbar though

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1990
i just tested both and they work fine if i comment out the lines in on_paint which draw the images (because i obviously don't have them).

  • nikolai4ik
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #1991
i just tested both and they work fine if i comment out the lines in on_paint which draw the images (because i obviously don't have them).

I'll try again, sorry if that was indeed the mistake, quite dumb from me then 

br3tt, while I was trying to fix the seekbar I've tried all your other configs and now spending quite some time tinkering with foorazor which uses most of the scripts you posted here before. Is it possible in your WSH Playlist Viewer v2.1.0 to collapse non active groups (like elplaylist does) and is it possible to add an A-Z quick jump browser with WSH?


and I guess it's impossible to chande DUI's color of splitters/tabs/etc? It's controlled by OS?
  • Last Edit: 22 January, 2013, 06:19:29 AM by nikolai4ik

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1992
and I guess it's impossible to chande DUI's color of splitters/tabs/etc? It's controlled by OS?


right. but you can get 3rd party themes. check somewhere like deviantart.com

  • antheo
  • [*]
WSH Panel Mod script discussion/help
Reply #1993
@ marc2003, Falstaff or someone, could you please help me a simple script using WSH panel mod which can make an image (like a vinyl disc) rotate/stop when playing/stopping a song? thank you in advance. 

WSH Panel Mod script discussion/help
Reply #1994
antheo

Here's very simple script for rotating image on playback time.

Code: [Select]
var image = gdi.Image(fb.FoobarPath + "images\\vinyl.jpg");
var angle = 0;

function on_paint(gr) {
  
   gr.DrawImage(image, 0, 0, 500, 500, 0, 0, image.width, image.height, angle);

}
function on_playback_time(time){
  
   if(angle >= 360) angle = 0;
   angle += 60;
   window.Repaint();   
  
}

I tested it with this Vinyl image
  • Last Edit: 22 January, 2013, 02:50:08 PM by ExtremeHunter

  • Falstaff
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1995
too slow

  • antheo
  • [*]
WSH Panel Mod script discussion/help
Reply #1996
antheo

Here's very simple script for rotating image on playback time.

Code: [Select]
var image = gdi.Image(fb.FoobarPath + "images\\vinyl.jpg");
var angle = 0;

function on_paint(gr) {
  
   gr.DrawImage(image, 0, 0, 500, 500, 0, 0, image.width, image.height, angle);

}
function on_playback_time(time){
  
   if(angle >= 360) angle = 0;
   angle += 60;
   window.Repaint();   
  
}

I tested it with this Vinyl image


Thank ExtremeHunter so much for this script, I already tested it but as Falstaff said it too slow, could you give me a little time to make it rotate faster? (at least 12 frames/per second).
Here is my skin and I like to update it with a vinyl disc rotate as a new visualization


Anyways, thank you again and look for your help.

WSH Panel Mod script discussion/help
Reply #1997
Ok here's the faster one with timer .

Play with the values to make it faster/slower.

Code: [Select]
var vinylImage = gdi.Image(fb.FoobarPath + "images\\vinyl.jpg");
vinylImage = vinylImage.resize(300, 300);
var angle = 0;

var vinylX = 20;
var vinylY = 20;
var vinylW = vinylImage.width;
var vinylH = vinylImage.height;

function on_paint(gr) {

   gr.DrawImage(vinylImage, vinylX, vinylY, vinylW, vinylH, 0, 0, vinylW, vinylH, angle);

}

var rotationInterval = 50;
var rotationTimer;
var rotationTimerStarted = false;

function onRotationTimer() {

   if (!rotationTimerStarted) {

       rotationTimer = window.SetInterval(function () {

           if (angle >= 360) angle = 0;
           angle += 10;
           window.RepaintRect(vinylX, vinylY, vinylH, vinylH);

       }, rotationInterval);



       rotationTimerStarted = true;
   }

}

function stopRotationTimer() {

   window.ClearInterval(rotationTimer);
   rotationTimerStarted = false;

}

function on_playback_stop(reason) {

   if (reason != 2) {

       stopRotationTimer();

   }

}

function on_playback_pause(state) {

   if (state) stopRotationTimer();
   else onRotationTimer();

}

function on_playback_new_track() {

   onRotationTimer();

}

  • antheo
  • [*]
WSH Panel Mod script discussion/help
Reply #1998
Ok here's the faster one with timer .

Play with the values to make it faster/slower.

Code: [Select]
var vinylImage = gdi.Image(fb.FoobarPath + "images\\vinyl.jpg");
vinylImage = vinylImage.resize(300, 300);
var angle = 0;

var vinylX = 20;
var vinylY = 20;
var vinylW = vinylImage.width;
var vinylH = vinylImage.height;

function on_paint(gr) {

   gr.DrawImage(vinylImage, vinylX, vinylY, vinylW, vinylH, 0, 0, vinylW, vinylH, angle);

}

var rotationInterval = 50;
var rotationTimer;
var rotationTimerStarted = false;

function onRotationTimer() {

   if (!rotationTimerStarted) {

       rotationTimer = window.SetInterval(function () {

           if (angle >= 360) angle = 0;
           angle += 10;
           window.RepaintRect(vinylX, vinylY, vinylH, vinylH);

       }, rotationInterval);



       rotationTimerStarted = true;
   }

}

function stopRotationTimer() {

   window.ClearInterval(rotationTimer);
   rotationTimerStarted = false;

}

function on_playback_stop(reason) {

   if (reason != 2) {

       stopRotationTimer();

   }

}

function on_playback_pause(state) {

   if (state) stopRotationTimer();
   else onRotationTimer();

}

function on_playback_new_track() {

   onRotationTimer();

}


Haha, good job ExtremeHunter, it work well and I will try to fix it with seekbar so let them work look like a vinyl disc player with a (seekbar) needle.

Thank so much 

  • derty2
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #1999
That's a really nice disc spinner visualization you made there ExtremHunter, congrats +++++

Unfortunately for me, it won't resize to fill the whole panel window. I drag the panel edges open and the disc wants to stay one size at top left.
Is there any chance you can add more code to (A) center the disc in the panel and (B) make the disc auto-resize to fit the whole panel.

Great job on this, it would be nice if you continued to develop the script with more features :-) . . . . . Just off the top of my head, a super-cool feature would be if you could right-click the panel and choose menu items "Zoom In" or "Zoom Out" in incremental steps . . . . for example, if we continue to zoom in, then the disc stays always centered in the panel but the image goes beyond the edges of the panel, so with high enough zoom-in level we are looking at the hole in the middle of the disc filling the whole panel !!

I added this preamble header to the current script:
Quote
//////////////////////////////////////////////////////////////////////////////////////
// "Spinning Disc Image Viewer"
// WSH Panel Mod script by ExtremeHunter (Jan 23, 2013)
// creates a visual effect of a spinning disc as track is playing.
//
// script source:
// www.hydrogenaudio.org/forums/index.php?showtopic=77883&view=findpost&p=821699
///////////////////////////////////////////////////////////////////////////////////////
  • Last Edit: 23 January, 2013, 10:41:48 AM by derty2