Skip to main content

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

0 Members and 2 Guests are viewing this topic.
  • tarkus721
  • [*]
WSH Panel Mod script discussion/help
Reply #2275
Hi marc!

Your News / Reviews / Blogs wsh panel crashes when scrolling down (mouse wheel) on 'Reviews' view if the artist name contains an ampersand.
ex: Emerson, Lake & Palmer; Bog Seger & The Silver Bullet Band.

Error: WSH Panel Mod (News / Reviews / Blogs by marc2003): Microsoft JScript runtime error:
Invalid procedure call or argument
File: C:\My Applications\Placebo Monolithic\foobar2000\marc2003\common7.js
Ln: 1615, Col: 6
<source text only available at compile time>

Thanks

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2276
it's not the ampersands. i can't explain why but some of the article's text consists of a single space and that is causing the problem. anyway, fixed version uploaded. right click>Update script.

changelog - https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt
full download  - https://dl.dropboxusercontent.com/u/22801321/samples.zip

  • tarkus721
  • [*]
WSH Panel Mod script discussion/help
Reply #2277
That did the trick...thanks! 

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2278
hey marc,
say my code for a button for the time being is:
Code: [Select]
//...
//tipText = {normal: "Next", alternate: "Random"}
//func = function(){fb.next();}
//altFunc = function(){fb.random();}

function Button(x, y, w, h, defaultImage, hotImage, func, tipText, altFunc)
{
    //...

    if(altFunc === null){
        this.altFuncFlag = false;
    }
    else{
        this.altFuncFlag = true;
        this.altFunc = altFunc;
    }
}

what i want to do is check if the altFunc parameter was passed within the button function.
so i start the if condition to do my business as:
if(is there an altFunc?){...}

but how should i go about it?
  • Last Edit: 18 April, 2013, 10:04:30 AM by matav
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2279
that looks rather complicated. for buttons without an alternate function, just assign the normal function to the variable.

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2280
that looks rather complicated...
true that but i am basically modding T.P. Wang & Tedgo's script for the moment.
So, i am kinda messing it up (progressively but i am happy with the results)

i did, however, achieve this (thanks to this link at stackoverflow)

now, i have it done this way:
Code: [Select]
//func = function(){fb.next();}
//func_alt = function(){fb.random();}

function Button(x, y, w, h, img_src, func, tiptext, func_alt) {
    //...

    this.func = func;

    if(typeof func_alt === 'undefined'){
        this.func_alt_flag = false;
    }
    else{
        this.func_alt_flag = true;
        this.func_alt = func_alt;
    }
}

and for buttons without any alternate function, it doesn't matter cuz that's where the the flag comes handy (the only place it comes handy)
  • Last Edit: 18 April, 2013, 02:46:27 PM by matav
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2281
this is how i'd do it.

Code: [Select]
this.func = func;
this.func_alt = func_alt || func;


if func_alt is undefined, it will use the default function.

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2282
lol
that's even better
*sigh*

thanks


--
  • Last Edit: 18 April, 2013, 03:03:38 PM by matav
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

  • Curly
  • [*]
WSH Panel Mod script discussion/help
Reply #2283
Hi!

I am using this script as a volume bar;


Quote
// vi:set ft=javascript ff=dos ts=4 sts=4 sw=4 et:

// ==PREPROCESSOR==
// @name "Volbar"
// @author "T.P Wang"
// ==/PREPROCESSOR==

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

// gdi.Font is changed, the last paramter is style flags
// FontStyleRegular = 0,
// FontStyleBold = 1,
// FontStyleItalic = 2,
// FontStyleBoldItalic = 3,
// FontStyleUnderline = 4,
// FontStyleStrikeout = 8
// Here is 0, means FontStyleRegular
var g_font = gdi.Font("Tahoma", 12, 0);
var g_drag = 0;

function on_paint(gr) {
    gr.SetTextRenderingHint(5);
    var ww = window.Width;
    var wh = window.Height;
    var volume = fb.Volume;
    var pos = window.Width * ((100 + volume) / 100);
    var txt = (Math.ceil(volume)) + "dB";
    gr.FillGradRect(0, 0, pos, wh, 90, RGB(240, 240, 240), RGB(100, 230, 100));
    gr.FillGradRect(pos, 0, ww - pos, wh, 90, RGB(240, 240, 240), RGB(190, 190, 190));
    gr.DrawString(txt, g_font, RGB(64, 64, 128), 0, 0, ww, wh, 0x11005000);
    gr.DrawRect(0, 0, ww - 1, wh - 1, 1.0, RGB(150, 150, 150));
}

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;
}

function on_mouse_move(x, y) {
    if (g_drag) {
        var v = x / window.Width;
        v = (v < 0) ? 0 : (v < 1) ? v : 1;
        v = -100 * (1 - v);
        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();
}


Is there any way of modifying this script to act as a seekbar?

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2284
curly... you want to modify this sample or simply want a seekbar?
cuz imho, to make this a seekbar is as good as modifying the entire script.

if you want a similar type seekbar then check this post:
http://www.hydrogenaudio.org/forums/index....st&p=628170
...the one starting with "var DT_TOP = 0x00000000;"
  • Last Edit: 22 April, 2013, 04:35:27 PM by matav
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

  • Curly
  • [*]
WSH Panel Mod script discussion/help
Reply #2285
curly... you want to modify this sample or simply want a seekbar?
cuz imho, to make this a seekbar is as good as modifying the entire script.

if you want a similar type seekbar then check this post:
http://www.hydrogenaudio.org/forums/index....st&p=628170
...the one starting with "var DT_TOP = 0x00000000;"


Thanks for the help! Got it working.

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2286
yes that's definitely possible.

this is the callback for a left mouse click and you can check whether shift was held.

Code: [Select]
function on_mouse_lbtn_up(x, y) {
    if (utils.IsKeyPressed(0x10)) {
        //shift key was pressed. do something
    } else {
        //do something else
    }
}

hey marc, i was reading Flags.html and was wondering whether i can skip "utils.IsKeyPressed(...)" and use the flag mask "MK_SHIFT" in, say, "on_mouse_lbtn_up(x, y, mask) {}".
but since i don't have much experience in WSH/jscript per say, i am unable to get this to work.

i am doing it so:
Code: [Select]
var MK_SHIFT = 0x0004;
function on_mouse_lbtn_up(x,y,MK_SHIFT){
    fb.trace("something");
}
but it ignores the mask and works like a normal mouse callback function.

i can't figure out what i may be doing wrong.
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

WSH Panel Mod script discussion/help
Reply #2287
function on_mouse_lbtn_up(x, y, mask){
   
    if (mask == 4) {
        //shift key was pressed. do something
    } else {
        //do something else
    }
   
}

  • matav
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2288
aah...
thanks
try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2289
samples updated: https://dl.dropboxusercontent.com/u/22801321/samples.zip

changelog: https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt

Quote
added new "last.fm album info" script. just be aware
many albums have no content. however, clicking the
logo should open the last.fm website on
most album pages.


  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2290
samples updated: https://dl.dropboxusercontent.com/u/22801321/samples.zip

changelog: https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt

new script: spectrogram seekbar



notes-
-it requires ffmpeg and SOX. download links are in the script.
-because it uses ffmpeg for decoding files, you're limited to the codecs it supports. what foobar input components you might have are irrelevant.
-images are generated automatically as songs are played. there can be a delay of a few seconds when playing something for the first time. foo_wave_seekbar users should be used to this.
-current settings create images around 80KB in size per track. these are stored in a folder inside your foobar2000 profile.
-tooltips indicate track position without having to drag
-does not support cuesheets

files changed / added:
Code: [Select]
marc2003\common7.js
marc2003\images\hourglass.png
samples\spectrogram seekbar.txt
  • Last Edit: 25 April, 2013, 12:23:40 AM by marc2003

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2291
samples updated: https://dl.dropboxusercontent.com/u/22801321/samples.zip

changelog: https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt

Quote
7.2013.04.25.02

"Spectrogram seekbar". Bugfix. Panel would show previous
spectrogram when switching to an unsupported format like
a stream.


files changed:
Code: [Select]
marc2003\common7.js
samples\spectrogram seekbar.txt

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2292
samples updated. same links as above. added a few options to my spectrogram seekbar script.



other seekbars have been cleaned up slightly.

files changed:
Code: [Select]
marc2003\common7.js
samples\nyan cat seekbar.txt
samples\simple seekbar.txt
samples\spectrogram seekbar.txt
samples\themed seekbar.txt

  • r0k
  • [*][*]
WSH Panel Mod script discussion/help
Reply #2293
Hi marc. Nice addition to your panels. Couple suggestions, feel free to ignore them 
  • Name is quite long as you use the full path. I'm not sure how much you can put in a filename in windows 7/8 but i'm surprised my system doesn't complain names are too long. This might cause some issues if the path is compicated. Maybe using some sort of crc32 or hash of the music file would be better. Not sure it's possible.
  • Reading the panel size from and producing a spectro image fitting the panel would give a cleaner display.
  • You can reduce the size of the png images in the cache ( to about 2/3 of their size in my tests) by using OptiPNG. It's only a 97k command line portable tool (and open source like all tools you've used so far).


BTW, as i was posting this, i just had your "Now Playing" panel crash on me out of the blue
Code: [Select]
WSH Panel Mod (Now Playing by marc2003): initialized in 17 ms
Error: WSH Panel Mod (Now Playing by marc2003): Erreur d'exécution Microsoft JScript:
Objet requis
File: C:\Users\Roland\AppData\Roaming\foobar2000\marc2003\common7.js
Ln: 1393, Col: 4
<source text only available at compile time>

Looks like it's pointing to this part of common7.js
Code: [Select]
function cd(x, y, w, h) {
    this.draw = function(gr) {
        if (this.shadow) p.draw_image(gr, this.shadow_img, this.x, this.y, this.w, this.h, "centre");
        p.draw_image(gr, this.case_img, this.x, this.y, this.w, this.h, "centre");
        if (this.img) {
→           this.ratio = Math.min(this.w / this.case_img.Width, this.h / this.case_img.Height);
            this.nw = 488 * this.ratio;
            this.nh = 476 * this.ratio;
            this.nx = Math.round((this.w - (452 * this.ratio)) / 2);
            this.ny = Math.round((this.h - this.nh) / 2);
            p.draw_image(gr, this.img, this.nx + this.x, this.ny + this.y, this.nw, this.nh, "crop");
        }
        p.draw_image(gr, this.semi_img, this.x, this.y, this.w, this.h, "centre");
        if (this.gloss) p.draw_image(gr, this.gloss_img, this.x, this.y, this.w, this.h, "centre");
    }
    ...

This all occured at the same time i had my Router crash, as i've noticed when trying to post this i no longer had internet connection. Probably related to the LastFM biography.

EDIT : On the other hand, it might be totally unrelated. I have the panel crashed again right now, and still have Internet access.
  • Last Edit: 25 April, 2013, 01:53:02 PM by r0k

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2294
i've just removed the spectrogram seekbar from the zip temporarily because it randomly crashes on track changes and i can't figure out why. it's been fine all afternoon but it's just started playing up now. 

spectrogram seekbar has been restored. it should be ok now. just right click>update script to fix.

@r0k, that error would suggest it can't find the case images. but if you've been using it for sometime without issue then i have no idea what would cause it to go wrong all of a sudden.
  • Last Edit: 25 April, 2013, 03:00:50 PM by marc2003

  • r0k
  • [*][*]
WSH Panel Mod script discussion/help
Reply #2295
OK. I re-extracted the zip and it's working again. For whatever reason this picture had gone missing. Don't know how it got removed ...
  • Last Edit: 25 April, 2013, 05:01:00 PM by r0k

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2296
about your other points, i'll consider adding an option where you can specify SOX parameters yourself for image creation.

  • PeteG
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #2297
@marc2003 | Spectrogram Seekbar

Thank you very much for your latest brainchild  . The time tooltip is one of those details that comes in very handy.
A minor problem (for me, that is) has however popped up: Either ffmpeg or Sound eXchange are having problems with at least some 'foreign' characters resulting in nil output to screen and disk.
No blurps from the Console with fb.trace activated in the front end script:

Code: [Select]
Opening track for playback: "H:\Rhythmic\K\Aiko Kitahara\Piece Of Love\05 - サヨナラを告げた日が近すぎて.mp3"
cmd /c ""C:\Users\PG\AppData\Roaming\foobar2000\sox\ffmpeg.exe" -i "H:\Rhythmic\K\Aiko Kitahara\Piece Of Love\05 - サヨナラを告げた日が近すぎて.mp3" -f
sox - | "C:\Users\PG\AppData\Roaming\foobar2000\sox\sox.exe" -p -n channels 2 spectrogram -d 3:27 -Y 2000 -r -o
        "C:\Users\PG\AppData\Roaming\foobar2000\spectrogram_cache\HRhythmicKAiko KitaharaPiece Of Love05 - サヨナラを告げた日が近すぎて.mp3.png""

Opening track for playback: "H:\Rhythmic\M\Magma\Üdü Wüdü\01 - Üdü Ẁüdü.flac"
cmd /c ""C:\Users\PG\AppData\Roaming\foobar2000\sox\ffmpeg.exe" -i "H:\Rhythmic\M\Magma\Üdü Wüdü\01 - Üdü Ẁüdü.flac" -f
sox - | "C:\Users\PG\AppData\Roaming\foobar2000\sox\sox.exe" -p -n channels 2 spectrogram -d 4:17 -Y 2000 -r -o
        "C:\Users\PG\AppData\Roaming\foobar2000\spectrogram_cache\HRhythmicMMagmaÜdü Wüdü01 - Üdü Ẁüdü.flac.png""

Notice the 'Ẁ'.
I've changed channels to 2 and the Y parameter to 2000, but the innate values make of course no difference.
A shot in the dark: creating png file and writing to disk fails. Maybe another file naming schema would eliminate the problem? md5 or what do I know?

Btw, I'm trying to figure out how to change SoX' standard colours to something that's matching my layout. Not an easy task it seems.








  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2298
^i now use the $crc32 title formatting function on the path. hopefully that will resolve it.

right click>Update script should work for current users.

samples updated: https://dl.dropboxusercontent.com/u/22801321/samples.zip

changelog: https://dl.dropboxusercontent.com/u/2280132...h/changelog.txt

Quote
7.2013.04.26.01

"Spectrogram seekbar". The naming scheme for images has
been changed so you should clear all old files using the
right click menu. You can now set SOX parameters via a
dialog. See sox.pdf for all options. These
parameters also form part of the cached image filename
so changing them will update the display immediately.



files changed:
Code: [Select]
marc2003\common7.js
  • Last Edit: 26 April, 2013, 06:37:50 AM by marc2003

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #2299
i meant to edit my previous post and not post a new reply. delete me please.
  • Last Edit: 26 April, 2013, 06:34:07 AM by marc2003