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: JScript Panel script discussion/help (Read 288680 times) previous topic - next topic
MaFred and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #275
I'd like to adjust the size of JS panel with foobar resizing as follows.
In other words, the size of JS panel shoud change proportionally with the main foobar window size.

Is ther any method to retrieve the foobar window size into the JS panel for this purpose?



Re: JScript Panel script discussion/help

Reply #276
That's something foobar does by default with all panels - assuming you don't lock any splitters.

Re: JScript Panel script discussion/help

Reply #277
That's something foobar does by default with all panels - assuming you don't lock any splitters.
Thank you for your reply.

More specifically, what I want to do is
In the max foobar size, I fixed the JS panel width/height = 600/400.

function on_size() {
    ww = window.Width;
    wh = window.Height;
 
    window.MinWidth = 600;
    window.MaxWidth = 600;

    window.MinHeight = 400;
    window.MaxHeight = 400;
}

And,, then I resize the foobar window size to the x% of the max foobar size.
In this case, I want to resize JS panel width/height = (600/400) * x/100.

Is this possible?

Re: JScript Panel script discussion/help

Reply #278
Well of course it won't work if you're locking the size. Read my post again.

Re: JScript Panel script discussion/help

Reply #279
Well of course it won't work if you're locking the size. Read my post again.
I'm sorry for the uncertain question.
My question is, if I can adjust the values as follows with not fixed, but as variables
    window.MinWidth = 600;   --> window.MinWidth = 0.4 x (Foobar window width)
    window.MaxWidth = 600;   --> window.MinWidth = 0.4 x (Foobar window width)

Re: JScript Panel script discussion/help

Reply #280
I start off with a small window and my JScript Panel is just over one third of foobar's width. I resized the splitter manually...

http://i.imgur.com/jbzzp8Y.png

Now I max the window and foobar has kept the same proportions. No script, no locked splitters.

http://i.imgur.com/MQ6eKSu.png

edit: I don't think you will be able to set a min width because then foobar will forget the proportions when you start going larger again.

I suppose you could have another panel taking up the entire width and have that notify your other panel when it is resized. I'll post something for that later but I have to go out now.

Re: JScript Panel script discussion/help

Reply #281
I start off with a small window and my JScript Panel is just over one third of foobar's width. I resized the splitter manually...

http://i.imgur.com/jbzzp8Y.png

Now I max the window and foobar has kept the same proportions. No script, no locked splitters.

http://i.imgur.com/MQ6eKSu.png
OK. I got it. Thank you for your time and help.

Re: JScript Panel script discussion/help

Reply #282
I'm using "now playing (basic)" script after small modification like this

Code: [Select]
var ft1 = 50, ft2 = 42, ft3 = 30, y1 = 0, y2 = 75, y3 = 150;

//the track info section displays 4 lines of title formatted text. you can customise that here/////////////////////////////////////////////

var line1 = {
text: "", //leave this blank
tf: "$if2(%artist%,No Artist Info)", //enter any title formatting
font: _.gdiFont("Segoe UI", ft1, 1), //font name, size, style. 1 means bold and 0 is normal.
colour: _.RGB(40, 40, 40), //colour
y: y1 //change this value to move text up or down.
}
var line2 = {
text: "",
tf: "$if2(%title%,No Song Info)",
font: _.gdiFont("Segoe UI", ft2, 1),
colour: _.RGB(90, 90, 90),
y: y2
}
var line3 = {
text: "",
tf: "$if([%album% ]['('%date%')'],[%album% ]['('%date%')'],No Album Info)",
font: _.gdiFont("Segoe UI", ft3, 1),
colour: _.RGB(140, 140, 140),
y: y3
}

And, I'm trying to change the font & location of line1, line2, line3 after getting a notification from another panel.
I've put "window.NotifyOthers("width_notify",ww);" within 'function on_size()' in another panel.
So, I inserted the following code to change the font size and location.
Code: [Select]
function on_notify_data(name, info) {
    if(name=="width_notify") {
        if(info==1920) {
            ft1 = 50, ft2 = 42, ft3 = 30, y1 = 0, y2 = 75, y3 = 150;
            window.Repaint();
        } else {
            ft1 = 30, ft2 = 22, ft3 = 15, y1 = 0, y2 = 40, y3 = 80;
            window.Repaint();
        }
    }
}

But this dosen't work for my purpose. I'm not familiar with the programming language.
So, please give me some hint.

Re: JScript Panel script discussion/help

Reply #283
You're basically doing this...

Code: [Select]
var a = 1;
var b = a;

function blah() {
    a = 2; // now you're expecting "b" to take on the new value of "a" which is never going to work
}

You need to update the variables directly

Code: [Select]
line1.font = 50;
line1.y = 0;
...

Re: JScript Panel script discussion/help

Reply #284
You're basically doing this...

Code: [Select]
var a = 1;
var b = a;

function blah() {
    a = 2; // now you're expecting "b" to take on the new value of "a" which is never going to work
}

You need to update the variables directly

Code: [Select]
line1.font = 50;
line1.y = 0;
...
Thank you for your help. The following is what I'm using now.
Code: [Select]
function on_notify_data(name, info) {
    if(name=="width_notify") {
        if(info==1920) {
            line0.font = _.gdiFont("Cambria", 110, 1);
            line0.y = 0;
            window.Repaint();
        } else {
            line0.font = _.gdiFont("Cambria", 80, 1);
            line0.y = 20;
            window.Repaint();
        }
    }
}

Re: JScript Panel script discussion/help

Reply #285
Again, me.. :-[

Is there any method to make a shadow effect on the "now playing panel" text?

Re: JScript Panel script discussion/help

Reply #286
Draw the text twice and have a slight offset between each one's x and y positions. Also some contrasting colour would help.

Or if you want something more fancy, see the samples folder inside the component directory>glow text sample.txt

Re: JScript Panel script discussion/help

Reply #287
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

This works great marc.  Still am naming all my album cover art %album%, so it's nice this works since the last time I stumbled around a script.

I wonder if you could help me with a problem I'm having with br3tt's smooth playlist script marc.  For the thumbnail cache files created in '\js_br3tt\cache\imgcache' the script looks to the track's folder, and it seems like if it doesn't find any variations in the script, it selects the 1st jpg in the folder with *.* and uses that.  I tried with limited success to change the code for name of the files the cache uses from:

Code: [Select]
masks: window.GetProperty("_PROPERTY: Cover art masks (used for the cache)","*front*.*;*cover*.*;*folder*.*;*.*"),
to just:
Code: [Select]
masks: window.GetProperty("_PROPERTY: Cover art masks (used for the cache)","%album%.*"),

It seemed like when a cache file wasn't already made, that tended to work.  But in later attempts it seemed that wasn't the case, and the script would just choose the 1st jpg in the folder it pleased.

And I've found no way to clear the cached file for the thumbnails that are wrong without deleting the entire cache folder.

Any ideas on how to address these probs?

Another problem came up.
It seems that if I create an empty image (gdi.CreateImage), and write some text in it (GdiDrawText), the edge of the characters' shape are seen as 1px dark lines. If the image is going to be used on a white background, the dark edges can be annoying.
Are there any methods to avoid them, without giving up using gdi.CreateImage? I thought this was due to SetTextRenderingHint, but soon it was denied in experiments.
screenshot:

I'd really love to have this set up in my build to enable quick playback order preferences.  Anywhere I can grab the code for this and the graphic?



Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #288
I need to rework that album art script because it doesn't account for people using title formatting with the filename. Currently it won't work if the album contains characters that are illegal in windows. I'll post an update later.

As for looking at Falstaff/Br3tt's other scripts... nope. I made some minor mods to jsplaylist because I use it everyday. I have no interest in other people's scripts that I don't use.

Re: JScript Panel script discussion/help

Reply #289
A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.

Sorry I forgot about this. It's now a variable you set at the start of the script.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

It also handles illegal characters that may be contained in any title formatting used for the filename.

Re: JScript Panel script discussion/help

Reply #290
I need to rework that album art script because it doesn't account for people using title formatting with the filename. Currently it won't work if the album contains characters that are illegal in windows. I'll post an update later.
OK.  I just set it up, so I haven't tested it a lot.  Will keep an eye out for your update.

Quote
As for looking at Falstaff/Br3tt's other scripts... nope.
I haven't checked recently, but Br3tt never seemed to hang out in the forums very much.  Think he'd notice if I addressed him here directly?  Or maybe I'd have better luck posting on his DeviantArt page.

... I made some minor mods to jsplaylist because I use it everyday.
That's a WSH panel script from his DeviantArt page, right?  I did give that try and had considered using it as an alternative.  But since I last posted, I've confirmed that both jsplaylist and his smooth playlist prevent FB2K from completely shutting down in Windows 10.  I had to delete panels 1 by 1 until I finally found the culprit.  Wonder if your mod would be any different.  Have you made it available for download anywhere?
Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #291
Sorry I forgot about this. It's now a variable you set at the start of the script.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

It also handles illegal characters that may be contained in any title formatting used for the filename.

This is crashing the panel when I replace the old code marc.
Geopoliticus Child Watching the Birth of the New Man

 

Re: JScript Panel script discussion/help

Reply #292
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).

It works good for me. Is there a simple script line I could add to automatically attach the picture to all the files in the folder after downloading it?
I'm late

Re: JScript Panel script discussion/help

Reply #293
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).

It works good for me.

Actually I realized it doesn't show the online pictures, even though it downloads them correctly.
I'm late

Re: JScript Panel script discussion/help

Reply #294
Actually I realized it doesn't show the online pictures, even though it downloads them correctly.

"online pictures"??  The script will crop a little of the borders.  Resizing the panel will show the edges better.  Not sure what you mean.

Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #295
Actually I realized it doesn't show the online pictures, even though it downloads them correctly.

"online pictures"??  The script will crop a little of the borders.  Resizing the panel will show the edges better.  Not sure what you mean.



I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?
I'm late

Re: JScript Panel script discussion/help

Reply #296
I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?

The script saves the graphic file in the same folder as the track, and is named: lastfm.jpg  Check the track folder to see if its there.
Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #297
I mean when the album art picture is missing from the local directory, isn't the script supposed to show the picture from the lastfm online resource?

The script saves the graphic file in the same folder as the track, and is named: lastfm.jpg  Check the track folder to see if its there.

Yes, that works and I managed to change the default picture name as I wanted. I just thought I could see a preview of the picture on the panel.
I'm late

Re: JScript Panel script discussion/help

Reply #298
The image should load when you skip forward a track, and then back up again if you have playback order set to default.  But you have to set FB2K to recognize the file name lastfm.jpg in preferences:

 Preferences > Display > Album Art > Front cover

What's your default cover art naming pattern?
Geopoliticus Child Watching the Birth of the New Man

Re: JScript Panel script discussion/help

Reply #299
The image should load when you skip forward a track, and then back up again if you have playback order set to default.  But you have to set FB2K to recognize the file name lastfm.jpg in preferences:

 Preferences > Display > Album Art > Front cover

What's your default cover art naming pattern?

$directory_path(%path%)\front.jpg (I edited the script accordingly at line 17) which I embed in the music files, so my jscript artreader is set to show the Icon. When there's no embedded icon (which usually means there's no front.jpg in the file directory either) the panel is a just a white background, even if the script finds the picture on lastfm and downloads it properly.
I'm late